Register and activate modules
With the registration.php and module.xml files created within our new Macademy_BestSelling module, our module contains everything that's needed to be registered and made visible to Magento.
Magento comes with a built-in command line tool, which you'll use to carry out many different tasks within Magento, a common one being enabling and disabling modules.
Let's go ahead and type
to see all of the available commands. We can take a quick look around to see everything that is available for us.
Feel free to check out all of these commands and read up on what's available, but at this time the commands we are looking for are located within the module grouping, specifically the module status and module enable command.
First let's type
This command displays the enable or disable status of all modules. We should see the Macademy_BestSelling module in this list under disabled. If you don't see it here, double check your vendor and module folder names for spelling mistakes or casing inconsistencies, then do the same for the registration.php and module.xml files, and their contents.
Next let's enable the module by typing
Next comes the module name. We'll use the VendorName_ModuleName format, so this would be Macademy_BestSelling.
bin/magento module:enable Macademy_BestSelling
At this point our module has been enabled. We'll see this message: "To make sure that the enabled modules are properly registered, run 'setup:upgrade'.", but you don't need to run this command unless your module contains database schema or update scripts.
The module:enable command is really just a helper for enabling modules. Even though it's not recommend, we can also enable modules manually.
Open up app/etc/config.php. This file simply returns an array of data, however it is a crucial file for Magento to operate. This file just contains modules now, but it can also contain overrides of other configuration values and other info. If a module is in this array and has a 1 it's enabled. If it has a 0 it's disabled. And if it isn't in this list at all, Magento isn't aware of the module.
You can manually trigger modules on and off by setting them to 1 and 0 in this file if you need to, but that really isn't recommend because there is some magic going on behind the scenes with the module:enable command.
Like all things which appear simple, this really isn't that simple. When you run module:enable, it does a bit more under the hood. This includes checking whether the module you are enabling depends on other modules, checking whether those modules are enabled, then checks whether the dependencies of those dependent modules are enabled, and so on up the tree.
It also uses that sequence node from module.xml files to determine exactly how to order modules within this config.php file. So generally, it's much safer to just use the command line when enabling or disabling modules to keep items within the config.php file in the proper order.