This docker setup has been tested with Magento 2, WordPress and Symfony 2 -> Symfony 4
- Install
dockeranddocker composeproperly - Clone project and
cdinto the that - Create configurations files (for the first time):
.env: define docker env variabledclamp.env: define PHP versions and servicesdocker-compose.yml: Docker compose file
./dclamp- Next time, you have to run
./dclamp configand./dclamp generateseparately.
- Generate wildcard self-signed certificates for
*.*.localhost(optional)
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout ./httpd/certs/x.x.localhost.key \
-out ./httpd/certs/x.x.localhost.crt \
-subj "/C=XX/ST=State/L=City/O=Company/OU=CompanySectionName/CN=*.*.localhost"- Create and run container:
docker compose up -d- Write your code at public_html directory
- Browse to URL:
localhost/info.phpto check if it's running properly - Your MariaDB database credentials:
root:1@localhost:3306orroot:1@mariadb:3306
- Default PHP version(s): latest PHP 8.x
- Assume your
index.phpis located at./public_html/project-dir/public-dir/index.php, please browse to:http://public-dir.project-dir73.localhostto run your application with PHP 7.3,http://public-dir.project-dir74.localhost(PHP 7.4)
- You don't have to add entry to
/etc/hosts/because by default, all .localhost sites will be redirected to 127.0.0.1:- If it's not the case, you can use dnsmasq instead of /etc/hosts, example:
# Redirect all localhost sites to 127.0.0.1
address=/localhost/127.0.0.1
- Add your VirtualHost config files to
./httpd/conf/vhosts/ - Restart Apache container:
docker restart httpd
- Run command
docker compose exec php73 /bin/bashor
docker compose exec php{xx} /bin/bash- Run you PHP application with command
php ... - To debug PHP CLI application: replace
phpbyxdebug- Example:
php bin/consoletoxdebug bin/console
- Example:
- After
docker compose exec...into container, run
toggle-php-mod xdebugor shortcut
toggle-php-mod xd- After
docker compose exec...into container, run
toggle-php-mod opcacheor shortcut
toggle-php-mod op