This docker setup has been tested with Magento 2, Wordpress and Symfony 2 -> Symfony 4
- Install docker and docker-compose properly
- Clone project and
cd
into the that - Create .env file
echo "UID=$UID" > .env
- 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@10.5.0.100:3306
orroot:1@maziadb:3306
- Default PHP version(s): PHP 7.3
- 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 exec -it php73 /bin/bash
or
docker exec -it 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 exec...
into container, run
toggle-php-mod xdebug
or shortcut
toggle-php-mod xd
- After
docker exec...
into container, run
toggle-php-mod opcache
or shortcut
toggle-php-mod op