Starting point Docker configuration for Symfony and other PHP projects (drupal, wordpress...).
CONTAINER | NOTES |
---|---|
PHP 7.4 | enabled |
NGINX 1.20 | enabled |
MYSQL 8.0 | enabled |
NODE 16 | enabled |
MAILDEV | enabled |
CONTAINER | NOTES |
---|---|
HTTPD 2.4 | optional, disabled |
BLACKFIRE | optional, disabled |
PHPMYADMIN | optional, disabled |
On first run :
$ make install
On next runs :
$ make start
- Copy this repository files and directory at the root of your php project.
- Copy the docker-compose.override.yml.dist file to docker-compose.override.yml.
- Add the docker-compose.override.yml file to .gitignore.
$ docker-compose build --pull
$ docker-compose up --build
$ docker-compose stop
$ docker-compose down --volumes --remove-orphans
$ docker-compose logs -f mysql
$ docker-compose exec mysql /bin/bash
$ docker-compose exec php /bin/bash
$ composer install
$ docker-compose exec php composer install
$ docker-compose exec mysql /bin/bash
$ mysql -uroot -p
$ mysql -uroot -p --host=127.0.0.1 --port=3306
$ docker-compose exec mysql sh -c 'exec mysqldump -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE"' > ./dump.sql
http://localhost (no extra step needed)
http://project.tld (add an entry "127.0.0.1 project.tld" to the host /etc/hosts file)
Uncomment the httpd section of the docker-compose.yml file and adapt the mapped ports in the docker-compose.override.yml file.
http://localhost:1080
Xdebug is enabled by default. However, it is necessary to use a browser's extension to catch it. Example of extensions for Google Chrome: xdebug helper
Configure your blackfire credentials in the docker/.env file. Uncomment the blackfire section in the docker-compose.yml and docker/php/Dockerfile files. See https://blackfire.io/docs/integrations/docker for more informations.
$ docker-compose exec blackfire blackfire curl http://nginx
$ docker-compose exec php /bin/bash
$ blackfire run php script.php
$ blackfire curl http://nginx
A tool like MySQL Workbench would be better but if you really want it uncomment the phpmyadmin section in the docker-compose.override(.dist).yml file.
http://localhost:8080