Create the initial module
Setting Up the Module Directory
To get started with this course, our first step is creating a module. We will create a standard Magento module that will contain all of the code we'll be experimenting with along the way. Assuming you are familiar with Magento 2, you'll know that all of our local development will go in the app/code
directory.
Let's go ahead and create a directory underneath app/code
named Macademy
. We'll create a subdirectory under that named JsFun
.
Creating the Registration File
In the JsFun
directory, create a new registration.php
file. This will let Magento know about our module on the PHP level. If you are taking this course, you should already be familiar with creating modules and classes, so we'll assume that you know all this.
Next, we'll name our module Macademy_JsFun
using the special string syntax. Save this file and proceed to the next step.
Creating the Module Configuration File
Create another file at etc/module.xml
. Here, we'll set up our boilerplate for our module using the Macademy_JsFun
string syntax. Save the file, and that's about all we need to set up our module.
Enabling the Module
Open up the terminal and enable our module by typing:
bin/magento module:enable Macademy_JsFun
This will take a moment, but eventually, our module will be enabled. We also need to flush the cache because we created some XML files and Magento caches these pretty heavily. Run the following command:
bin/magento cache:flush
This will take a second. When it's complete, we can check the status of our module by typing:
bin/magento module:status
After running this command, scroll up and see our module is in the list. This tells us our module is enabled and activated, and we'll be ready to start development.