So you’ve got an idea for an amazing new Magento 2 module and want to start coding right away. But before you can start you have to set up a Magento installation. And when you’re done, you probably want to test your module in other Magento installations with different versions.
m2devbox can help you with two things:
- automate the creation of Magento 2 installations
- automate the creation of a blank Magento 2 module along with a running installation
Make sure you have installed the requirements on your machine:
- Docker 17.05 or later
- PHP 7.4 or later
- php-zlib extension
Download the latest release of m2devbox from Github, make the PHAR file executable and optionally move it to a directory in your PATH, so that you can run it from everywhere:
wget https://github.com/MageGyver/m2devbox/releases/latest/download/m2devbox.phar chmod u+x m2devbox.phar mv m2devbox.phar /usr/local/bin/m2devbox m2devbox statusCode language: Bash (bash)
Automate the creation of Magento installations
With m2devbox you can easily start and stop multiple versions of Magento. Under the hood it uses pre-configured Docker containers:
m2devbox start 2.4.2-p1Code language: Bash (bash)
This command will start suitable Docker containers (for Apache, MariaDB and ElasticSearch), download and install Magento 2.4.2-p1.
On top of that, a directory called
app_code/ will be created in your current directory and it will be mounted into
/var/www/html/app/code/ so you can place your modules in it.
Currently m2devbox support all Magento 2 versions released 2020 and later – that means Magento 2.3.4 and above.
Automate the module creation
Additionally, m2devbox can assist you with creating a new blank module and starting a Magento 2 environment with it.
As a cherry on the cake it can generate PHPStorm project files with a full Magento 2 Plugin configuration. This way, PHPStorm coding assistances and indexes work with your Magento 2 environment.
The following command will create a PHPStorm project in the current working directory, add a
src/ directory containing a blank module named
MageGyver_DemoShipping and configure a Magento 2.4.2-p1 environment with it:
m2devbox start-module --vendor=MageGyver --module=DemoShipping --mage-version=2.4.2-p1 --phpstormCode language: Bash (bash)
Now you can start PHPStorm and open the newly created project directory. PHPStorm will start indexing the Magento source code. You can find your blank module under
app/code/MageGyver/DemoShipping and start coding! 🚀
Do you have suggestions or found a bug? Please feel free to open an issue at GitHub or share your thoughts in the comments below!