Working with modules in Magento 2
In this tutorial I show you how to work with modules in Magento 2. This has been completely changes since version 1. I show you how to install, activate and use modules. I will also give a basic knowledge on how to create Magento 2 modules.
Working with modules in Magento 2
Now modules are stored completely into one single directory under app/code. This has one major advantage: we do not need to search under app/code/local or app/code/community, app/etc/modules or anywhere under app/design for module files. This complicated structure leads to use of modman to enhance module creation. Now this is not necessary anymore. Modules are now detected on-the-fly. They do not need to get fetched into Magento Source structure. You only need to activate them. But first, start with something really easy:
1 | php bin/magento module:status |
This command lists all detected Magento 2 modules in your shop. It lists all activated and deactivated modules. Now it is very easy to get a fast an simple overview.
…
Enable Magento 2 modules
With this status list it is easy to see which module is active or disabled. Now we want to change that and to activate one of the disabled modules. For this we can use the following command:
1 | php bin/magento module:enable FireGento_FastSimpleImport |
As you can see it is very easy to activate a module. Magento 2 gives you a good feedback. If you reload your frontend/backend, you will get an error number. In your error report you will find the following error message:
“Please upgrade your database: Run “bin/magento setup:upgrade” from the Magento root directory.
We should upgrade our setup, so we do this with the following command:
1 | php bin/magento setup:upgrade |
Now everything works as expected. Your newly activated module runs.
Disable Magento 2 modules
Magento 2 offers you also an option to disable modules. With this command we can disable our previous enabled module:
1 2 3 | php bin/magento module:disable FireGento_FastSimpleImport <img class="alignnone size-full wp-image-115" src="http://mage2-blog.com/wp-content/uploads/2016/11/disable-magento2-module.png" alt="disable magento 2 module" width="1140" height="141" /> |
We do not need to additionally call setup:upgrade because there has nothing to be done. Your module is immediately deactivated.
Create your own module
As developer you have to make changes by modules. If you are new to Magento 2 it may be hard to start from the scratch. A good starting point is to use a module creator to get an empty running module to adjust it to do your intended tasks. My favorite creator is from Amasty. It creates a good Source for further working.
Conclusion
With Magento 2 module creation has changed a bit. For a developer with command line access it is now very easy to get an overview of all modules. You can easily activate or deactivate it. You don’t need to search for settings insige xml files.
thanks for sharing