This docker setup has been tested with Magento 2, WordPress and Symfony 2 -> Symfony 4
- Install
docker
anddocker compose
properly - Clone project and
cd
into the that - Create configurations files
.env
file
echo "UID=$UID" > .env
echo "XDEBUG_MODE=debug" >> .env
dclamp.env
file (define PHP versions and services)
# Choose what PHP version you want
echo "PHP_VERSIONS='8.1 7.4'" > dclamp.env
# For more services, see compose-declaration.yml
echo "ACTIVATED_SERVICES='httpd mariadb opensearch'" > dclamp.env
- Generate
docker-compose.yml
./dclamp generate
- Create and run container:
docker compose up -d
- Write your code at public_html directory
- Browse to URL:
localhost/info.php
to check if it's running properly - Your MariaDB database credentials:
root:1@localhost:3306
orroot:1@mariadb:3306
- Default PHP version(s): latest PHP 8.x
- Assume your
index.php
is located at./public_html/projectname/public/index.php
, please browse to:http://public.project.php73
to run your application with PHP 7.3,http://public.project.php74
(PHP 7.4)
- Tip:
- You can use dnsmasq instead of /etc/hosts, example:
# Redirect all sites in 4 domains (phpXX) to 127.0.0.1
address=/php71/php72/php73/php74/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/bash
or
docker compose exec php{xx} /bin/bash
- Run you PHP application with command
php ...
- To debug PHP CLI application: replace
php
byxdebug
- Example:
php bin/console
toxdebug bin/console
- Example:
- After
docker compose exec...
into container, run
toggle-php-mod xdebug
or shortcut
toggle-php-mod xd
- After
docker compose exec...
into container, run
toggle-php-mod opcache
or shortcut
toggle-php-mod op