Running mode: developer I was getting blank frontend page. I checked system.log and debug.log in magento and found out there was some errors related to some broken reference.

main.INFO: Broken reference: the 'logger' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
main.INFO: Broken reference: the 'theme.active.editor' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []

The frontend page was showing blank but it was actually loading some html. I check for solution and found an answer in this thread https://stackoverflow.com/questions/55928892/magento-2-blank-page-but-not-empty

This thread suggested to delete the global.php file located in generated/metadata, and following this solved my issue and front end of my website loaded properly.

But now whenever I run the command

php bin/magento setup:di:compile

the global.php file is generated again and my website's frontend shows blank page again and deleting global.php solves it. I got some information related to global.php file in this thread Purpose of magento\generated\metadata\global.php file and is it safe to delete this file?

According to above thread

"The code compiler creates generated/metadata/global.php, which is a PHP serialized map of all constructor definitions mixed with object linking configuration defined in di.xml. di.xml is the dependency injection configuration. There is a global app/etc/di.xml and there can one defined for every module ."

This also happens when I run my website in production mode, and deleting global.php solves it. Now my question is why magento is generating global.php file if it is neither using it in developer mode nor production mode as deleting this file does not give any error and the website works perfectly.

And also broken reference error in fresh install of magento, does it means that it is some bug related to magento and how can one debug this problem further. I am asking how to debug it because as we can see in the error there is no mention of any file just a reference 'after.body.start'.

Update: I am running it locally on my PC, and I am using xampp version-3.2.3 on windows operating system.


2 Answers 2


Goto Magento\Framework\View\Element\Template\File\Validator

Replace isPathInDirectories() function with bellow code

protected function isPathInDirectories($path, $directories)
    if (!is_array($directories)) {
        $directories = (array)$directories;
    $realPath = $this->fileDriver->getRealPath($path);
    $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
    foreach ($directories as $directory) {
        if (0 === strpos($realPath, $directory)) {
            return true;
    return false;

this will solve your problem

  • I have tried this method when I was getting blank admin page and yes this was the answer for that case. But here my question was related to global.php file and how to debug the issue "broken reference". Commented Jul 15, 2019 at 8:31

- Download Magento Project using composer

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.3.0

- Install Magento 2 using the command

php bin/magento setup:install --base-url="http://localhost/magento230" --db-host="localhost" --db-name=magento230_db --db-user=root --db-password=admin --admin-firstname="Admin" --admin-lastname="Magento" --admin-email="[email protected]" --admin-user="admin" --admin-password="admin@123" --use-rewrites="1" --backend-frontname="admin"

Install sample data modules:

  • Using composer:
  1. Add dependencies to the composer.json: composer require magento/module-bundle-sample-data magento/module-widget-sample-data magento/module-theme-sample-data magento/module-catalog-sample-data magento/module-customer-sample-data magento/module-cms-sample-data magento/module-catalog-rule-sample-data magento/module-sales-rule-sample-data magento/module-review-sample-data magento/module-tax-sample-data magento/module-sales-sample-data magento/module-grouped-product-sample-data magento/module-downloadable-sample-data magento/module-msrp-sample-data magento/module-configurable-sample-data magento/module-product-links-sample-data magento/module-wishlist-sample-data magento/module-swatches-sample-data magento/sample-data-media magento/module-offline-shipping-sample-data --no-update
  2. Run: composer update
  • Using magento:
  1. Deploy sample data: bin/magento sampledata:deploy
  2. Enable sample data modules (it's important!): bin/magento module:enable Magento_CustomerSampleData Magento_MsrpSampleData Magento_CatalogSampleData Magento_DownloadableSampleData Magento_OfflineShippingSampleData Magento_BundleSampleData Magento_ConfigurableSampleData Magento_ThemeSampleData Magento_ProductLinksSampleData Magento_ReviewSampleData Magento_CatalogRuleSampleData Magento_SwatchesSampleData Magento_GroupedProductSampleData Magento_TaxSampleData Magento_CmsSampleData Magento_SalesRuleSampleData Magento_SalesSampleData Magento_WidgetSampleData Magento_WishlistSampleData
  3. Remove old files: rm -rf var/cache/* var/page_cache/* var/generation/*
  4. Upgrade magento files: bin/magento setup:upgrade
  5. Recompile files: bin/magento setup:di:compile
  6. Do reindex: bin/magento indexer:reindex
  7. Deploy static content: bin/magento setup:static-content:deploy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.