Docker compose environment for Symfony (also works for Laravel or plain PHP) projects
- PHP 7.4.11 with XDEBUG 2.9.8
- Apache2
- MySQL 5.7
- PhpMyAdmin - manage MySQL
- Mailhog - local mailing server to test emails
- Installs
composer
andsymfony
commands - Virtualhost configuration dedicated for Symfony projects
- Latest stable NPM
- Latest stable Node.js
- Download
.docker
folder anddocker-compose.yml
file and add them to your project (Don't download.github
folder) - Run
docker-compose up
command from your terminal. (Install docker compose)
By default you can access services via:
- Access your project website via - http://192.168.2.2/
- MySQL can be accessed via 192.168.2.3:3306
- PhpMyAdmin can be accessed via http://192.168.2.4/
- Mailhog can be accessed via http://192.168.2.5:8025/
- Access docker apache-php terminal by writing -
docker exec -it project_web bash
If you use default IP addresses, append your .env
file with the following:
- For database connection -
DATABASE_URL=mysql://root:@192.168.2.3:3306/project
- For mailing server -
MAILER_URL=mailhog:1025//[email protected]:randompassword
(You don't need to change email or password)
- If you haven't modified IP addresses, you can connect to your MySQL via 192.168.2.3:3306
- If you don't have any additional software, you can connect to database via phpmyadmin (http://192.168.2.4/)
- Nickname:
root
- There is no password, leave blank for that
- Default table is called
project
- You cannot use same configuration for multiple projects. Docker won't allow you to allocate same IP addresses for multiple containers.
- You would need to modify
docker-compose.yml
IP addresses. For example from192.168.2.0/24
to192.168.3.0/24
- If you can't compose a new project, you might need to delete your old docker networks. Type
docker network ls
and then remove your old project network by writingdocker network rm NETWORK_ID
(for exampledocker network rm 528d8c753c17
) cannot start service XXX: network YYY not found
. Open up container list withdocker container ls -a
and remove old containers withdocker container rm ID
.develop_init.sh
Is not executable? Type -chmod +x ./.docker/develop_init.sh