- Docker (https://www.docker.com/products/docker#/windows) for windows should be installed.
- Run PowerShell as administrator and give permission to run scripts with command:
Set-ExecutionPolicy Unrestricted
- For Windows Shared Drivers in Docker Settings should be enabled
- Clone this repository && run
cd magento2-dev-box
in terminal - Run
.\m2devbox-init.ps1
in PowerShell - during command execution you will be asked for your magento repo credentials - Open in browser http://localhost:1748/
ℹ️ We suggest to make magento2-dev-box directory as your project directory in PhpStorm
If you want to configure PhpStorm automatically, run configure_php_storm
script. It will set up remote PHP interpreter.
- Create new server to PhpStorm Servers:
- Name: {{your server name}}
- Host: localhost
- Port: 1748
- Use path mappings: Yes
- File/Directory: magento2-dev-box/webroot-> /var/www/magento2
- Add PHP Remote Debug to new configurations in PhpStorm:
- Name: {{your name}}
- Servers: {{your server name from step 1}}
- Ide key: PHPSTORM
- Make sure that you have 9000 Xdebug port in Languages & Frameworks > PHP > Debug
To deploy static view files you need:
- Enter docker container by running:
docker exec -it --privileged {web container name} /bin/bash
- Enter magento root:
cd /var/www/magento2
- Deploy static files:
php bin/magento setup:static-content:deploy
To compile CSS out of LESS via Grunt you need:
- Enter docker container by running:
docker exec -it --privileged {web container name} /bin/bash
- Enter magento root:
cd /var/www/magento2
- Run:
cp Gruntfile.js.sample Gruntfile.js && cp package.json.sample package.json
- Run:
npm install & grunt refresh
- Go to Languages & Frameworks > PHP and add new Interpreter:
- Select Interpreter path: Remote
- Name: {{your_name}}
- Remote: SSH Credentials
- Host: 127.0.0.1 Port: 2222
- Username: magento2
- Password:
- PHP executable: /usr/local/bin/php
- Go to Languages & Frameworks > PHP:
- Interpreter: Remote PHP 7
- Path mapping: magento2-dev-box/shared/webroot -> /var/www/magento2
ℹ️ If your Magento is installed not in default location (/magento2-dev-box/shared/webroot) enter your custom location here.
- Go to Languages & Frameworks > PHP > PHPUnit and click +:
- Interpreter: Remote PHP 7
- Path mappings: magento2-dev-box/shared/webroot -> /var/www/magento2
- PHPUnit Library: Use Composer autoloader
- Path to script: /var/www/magento2/vendor/autoload.php
- If Xdebug does not work. Solution:
- For Mac OS run in terminal
ifconfig | grep inet
and get your ip address. Windows users check this article: https://support.microsoft.com/en-us/help/15291/windows-find-pc-ip-address - Go to web container:
docker exec -it --privileged {web container name} /bin/bash
- Within container go to:
/usr/local/etc/php/conf.d
- Open file:
vi docker-php-ext-xdebug.ini
- Start to edit it by typing:
i
- Add row:
xdebug.remote_host=<your_ip_from_step_1>
- Set:
xdebug.remote_connect_back=0
- Quit vi by typing:
Esc
->:wq
- Restart web container in your terminal:
docker restart {web container name}