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 (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 config
and./dclamp generate
separately.
- 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.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/project-dir/public-dir/index.php
, please browse to:http://public-dir.project-dir73.localhost
to 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/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