Categories


Archives


Recent Posts


Categories


Magento 2: Module Declaration Files

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

If you’re not paying attention, eBay has been a little more proactive on the Magento 2 front. The code dumps are coming regularly to git.

Of course, this means the shifts in architecture direction are also coming regularly to git.

In Magento 1 we had module declaration files. These lived in

app/etc/modules/*.xml

and “declared” a module in the system. Much like you’d edit /etc/apache2/conf/*.conf to configure virtual hosts in a web server, you’d edit files in app/etc/modules/*.xml to enable and disable modules in Magento.

The multiple configuration files (declaration file vs. etc/config.xml) confused a certain class of developer, so in early versions of Magento 2 the module declaration was moved into a module’s config.xml.

While this eliminated one extra configuration file, it did seems a little mind bending — in order to know if Magento should load a module’s configuration it needed to load a modules configuration?

Magento has addressed this in the latest builds of Magento 2. A new module configuration file, located in

app/code/Packagename/Modulename/etc/module.xml

was added to the system. This file is the new module declaration file, with a new syntax for module versions, active state, and a depends/sequence loading language. Checkout any of the default module’s module.xml for the specifics

./app/code/Magento/Adminhtml/etc/module.xml
./app/code/Magento/AdminNotification/etc/module.xml
./app/code/Magento/Authorizenet/etc/module.xml
./app/code/Magento/Backend/etc/module.xml
./app/code/Magento/Backup/etc/module.xml
./app/code/Magento/Bundle/etc/module.xml
./app/code/Magento/Captcha/etc/module.xml
./app/code/Magento/Catalog/etc/module.xml
etc ...

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 16th October 2013

email hidden; JavaScript is required