Just enough files to start Your Magento 2 module development. Based on Magento 2.3.4 CE.
- Create directory structure:
- In Your app/code directory create Your vendor/module directories, example: ExampleVendor/ExampleModule
- Create etc directory and add module.xml file:
- app/code/ExampleVendor/exampleModule/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="ExampleVendor_ExampleModule"/>
</config>
- Create registration file:
- app/code/ExampleVendor/exampleModule/registration.php
- Create registration file:
- app/code/ExampleVendor/exampleModule/registration.php
<?php
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'ExampleVendor_ExampleModule',
__DIR__
);
- Add composer.json:
- app/code/ExampleVendor/exampleModule/composer.json
{
"name": "example-vendor/module-example",
"description": "Example module description",
"type": "magento2-module",
"version": "1.0.0",
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"ExampleVendor\\ExampleModule\\": ""
}
},
"authors": [
{
"name": "Your Name",
"email": "[email protected]",
"homepage": "https://example.com/",
"role": "Developer"
}
]
}
- Last, but not least, add Your README file where You will put your module description:
- app/code/ExampleVendor/ExampleModule/README.md
# Example module
- Run module enable and setup upgrade with Magento 2 CLI:
$ bin/magento module:enable ExampleVendor_ExampleModule
$ bin/magento setup:upgrade
- After installation, Your module will be added to app/etc/config.php as item in modules array
- If You are working in git flow, Yoou need to add app/etc/config.php to your commit
Your final directory structure should look like this:
app/code/ExampleVendor/ExampleModule
├── composer.json
├── etc
│ └── module.xml
├── README.md
└── registration.php
Start coding!