5

I need to know, area wise config will load by application entry point files like /Magento/Framework/App/Http launch method.

But I'm not able to figure it out app/etc/di.xml config load.

1
  • @SivaKumarKoduru If you have additional questions, write them to me in comments, I will try to answer. May 14 '17 at 8:13
7
+50

File: vendor/magento/framework/App/ObjectManagerFactory.php

Line: 259 , method: _loadPrimaryConfig

Here the primary config (app/etc/di.xml) is loaded first time:

screenshot

All another di.xml was loaded in the:

  1. For the developer mode: Magento\Framework\App\ObjectManager\Environment\Developer::configureObjectManager()
  2. For the production mode: Magento\Framework\App\ObjectManager\Environment\Compiled::configureObjectManager()

by calling the:

$objectManager->configure(
    $objectManager
        ->get('Magento\Framework\ObjectManager\ConfigLoaderInterface')
        ->load(Area::AREA_GLOBAL)
); 

which loads instance of the Magento\Framework\App\ObjectManager\ConfigLoader and loads the config files in the load() method dynamically or from the cache (if enabled):

/**
 * {inheritdoc}
 */
public function load($area)
{
    $cacheId = $area . '::DiConfig';
    $data = $this->_cache->load($cacheId);

    if (!$data) {
        $data = $this->_getReader()->read($area);
        $this->_cache->save(serialize($data), $cacheId);
    } else {
        $data = unserialize($data);
    }

    return $data;
}

Result in the debug looks like this:

result in the debug

Then the result merges in the Magento\Framework\ObjectManager\ObjectManager::configure() method with initial config (app/etc/di.xml). All data are stored in the config attribute ($this->_config) of the ObjectManager.

2
  • Thank u what about modules di.xml
    – sivakumar
    May 10 '17 at 18:01
  • @sivakumar I improved the answer and added the information about the another scope configuration. I hope it will be useful for you. May 11 '17 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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