Create a Magento2 Module
-
Create module.xml file at app/code/VendorName/ModuleName/etc/module.xml;
- Next we will add our module to the global module list at app/etc/config.php.
#File: app/etc/config.php array ( 'Magento_Store' => 1, 'Magento_AdvancedPricingImportExport' => 1, 'Magento_Directory' => 1, //... 'VendorName_ModuleName'=> 1 ), ); - There’s one more step you’ll need to take. In addition to the files mentioned above, every module needs a registration.php file
#File: app/code/VendorName/ModuleName/registration.php
These files are identical for all modules, with the exception of the VendorName_ModuleName. There are a few different ways to check if a module’s installed correctly. One is to use the CLI application’s :
php bin/magento module:status
After installing a new module into the system, you may see the following error: “Please upgrade your database”, then you just run
php bin/magento setup:upgrade
If you saw your VendorName_ModuleName in the list, it means you successfully register your new module.