A near to perfect Magento2 Development Environment OS agnostic, OSX focused. Key features of the project:
Realpath
Make sure you have access to the below internal repoositories:
# Mutagen:
brew install mutagen-io/mutagen/mutagen
# Bash:
brew install bash
# Realpath:
brew install coreutils
You can download archive of this project on Release Page.
git clone git@github.com:yvoronoy/magento2docker.git
./bin/m2d setup init
.env
fileWith the default setup, Magento2Docker will use nip.io in this way:
http://{LEVEL_2}.{LEVEL_1}.127.0.0.1.nip.io
where:
Assume you have a multi-website Magento setup in the m246 folder; your domains can look like this:
To work with Magento2Docker you can use m2d
CLI command located in bin
of Magento2Docker project.
With Magento2Docker v3 it is super easy to start or stop containers:
# Display help
./bin/m2d --help
# To start containers:
./bin/m2d up
# To stop containers:
./bin/m2d stop
# To stop and remove containers and networks:
./bin/m2d down
# To enable service e.g. mailcatcher
./bin/m2d enable mailcatcher
# To disable service e.g. elasticsearch:
./bin/m2d disable search-engine
# To edit any .env parameter (e.g. PHP version):
./bin/m2d set M2D_WEB_SERVER_PHP_VERSION 8.1
# To display any .env parameter (e.g. search engine type):
./bin.m2d show M2D_SEARCH_ENGINE_VENDOR
# To start containers after enabling or disabling services or editing parameters:
./bin/m2d up --build
./bin/m2d go web
m2install.sh -s composer -v 2.4.6
./bin/m2d go web
m2install.sh
Containers with PHP 7.x have Composer 1 set as default, containers with PHP 8.x have Composer 2 set as default version.
./bin/m2d go web
sudo composer-link.sh 1
to use Composer 1sudo composer-link.sh 2
to use Composer 2The container already includes PHP xDebug extension. The xDebug extension is disabled by default because it is dramatically decrease performance.
./bin/m2d go web
sudo xdebug-php.sh 1
It requires two steps:
m2install
to use https.To use https install minica
: \
https://github.com/jsha/minica
After installation this library, you need to generate the wildcard certificate:
minica --domains '*.127.0.0.1.nip.io'
That will generate two files:
cert.pem
key.pem
Copy these files to your main directory src/html
.
You need to add cert.pem
to your system keychains.
cert.pem
.Check if your SSL certificate is ready to use inside the container:
$ bin/m2d go web
magento@b975beb70178:/var/www/html$ ls -la | grep cert.pem
-rw-rw-r-- 1 magento magento 1184 Jan 31 12:53 cert.pem
If you see the certificate, you can change the Apache configuration. Open two files:
web-servers/apache/etc/apache2/sites-enabled/000-default.conf
web-servers/apache/etc/apache2/sites-enabled/second-level.nip.io.conf
And remove comments from the section:
#<VirtualHost *:443>
# ...
#</VirtualHost>
When you uncomment this section in both files, rebuild the container:
$ bin/m2d up --build
Now, your webserver is ready to use https connections to the port 443.
m2install
to use httpsTo change the configuration to use https, you can edit or create a file:
/home/magento/.m2install.conf
Add or modify the environment variable:
HTTP_HOST=https://${CURRENT_DIR_NAME}.127.0.0.1.nip.io/
The host should start from https
, not http
.
Blackfire Profiler is a PHP profiler and automated performance testing tool. It enables you to investigate performance issues in very simple way, just install a browser extension and press the button. You will get granular performance report to measure CPU, IO, Memory, Network, etc. Profiling with Blackfire is on-demand. This means that Blackfire adds no overhead for your end users, which makes it safe to use in production.
Blackfire provides you a free account "Hack" which allows you to run profiles on your development environment.
./bin/m2d enable blackfire
./bin/m2d up --build
brew cask install xquartz
open -a XQuartz
and go to X11 Preferences
Run the following command inside env directory
docker-compose -f docker-compose.phpstorm.yml up -d --build
git checkout -b feature/my-cool-feature
.git commit -am 'Add some feature'
.git push origin feature/my-cool-feature
.Special thanks to @snosov and @tshabatyn who share their ideas and inspired to build this project.