-
-
Notifications
You must be signed in to change notification settings - Fork 2
Module structure
A module must have, at the very least:
module.xmlregistration.php
A module may also have an optional composer.json file.
Upon running bin/magento module:enable Vendor_Module:
#11 registration.php:5, require_once()
#10 NonComposerComponentRegistration.php:29, Magento\NonComposerComponentRegistration\{closure:/var/www/html/m2/research/m23-example-modules/html/app/etc/NonComposerComponentRegistration.php:29-29}()
#9 NonComposerComponentRegistration.php:29, array_map()
#8 NonComposerComponentRegistration.php:29, Magento\NonComposerComponentRegistration\{closure:/var/www/html/m2/research/m23-example-modules/html/app/etc/NonComposerComponentRegistration.php:18-31}()
#7 NonComposerComponentRegistration.php:33, require()
#6 autoload_real.php:73, composerRequirefe24ed7cfcf7e56742d967c8a9b0a516()
#5 autoload_real.php:63, ComposerAutoloaderInitfe24ed7cfcf7e56742d967c8a9b0a516::getLoader()
#4 autoload.php:7, include()
#3 autoload.php:30, require_once()
#2 bootstrap.php:33, require()
#1 magento:14, {main}()Starting at the bottom with stack frame:
-
#1,bin/magentois the entry point. -
#2initialises the Magento 2 environment. -
#3registers an autoloader and validates thatcomposer installhas been run. - These next three lines all call logic inside composer (and outside of Magento). They are all about loading autoloaders.
- This line includes a composer autoloader.
- This line includes a composer autoloader.
- Back in the Magento core,
NonComposerComponentRegistrationis a special file which contains a single function (it's not a method because it's not in a class). - This method, called
main, globs a list of components which cannot be autoloaded. These components are listed in the file itrequires,html/app/etc/registration_globlist.php. - The list of glob()bed files is iterated over with
array_map. - For each file in the glob()bed list, Magento 2 includes it with
require_once. - This is how the
registration.phpfile is read by Magento 2.
Each registration.php file calls \Magento\Framework\Component\ComponentRegistrar::register, which checks that the component is one of several pre-determined types (defined in \Magento\Framework\Component\ComponentRegistrar::$paths). That property eventually contains a list of all the components (modules, themes, etc) registered by Magento 2.
\Magento\Setup\Console\Command\AbstractModuleManageCommand::execute checks to see if there are any modules registered whose 'Status' has changed.
\Magento\Framework\Module\Status::checkConstraints checks to see if the module depends on any other modules.
\Magento\Framework\Module\Status::setIsEnabled enables the changed modules.
\Magento\Framework\App\Cache is cleaned.
\Magento\Framework\App\Filesystem\DirectoryList::GENERATED_CODE and \Magento\Framework\App\Filesystem\DirectoryList::GENERATED_METADATA folders are cleared.
Regeneration of generated files is requested by creating the flag .regenerate in var/