Docker compose to run PHP application, given Symfony configuration as an example.
- Create a
.env
from.env.dist
file, and customize it according to your preferences. - Update your hosts file according to the NGINX server configuration
# UNIX
sudo echo "0.0.0.0 lekode.dev" >> /etc/hosts
# Windows (edit C:\Windows\System32\drivers\etc\hosts)
- Build containers
docker-compose build
After building the containers, just run them and you’re ready to go
docker-compose up -d
Here is a list of things that can help you
- TODO: How to configure xDebug with a code editor. (an article that explain how to use it with your IDE.)
- TODO: Add other useful containers (Redis, phpMyAdmin …)
- TODO: Customize NGINX for other frameworks than Symfony (Add .conf file per framework)
You may need to execute commands inside php-fpm container to clear Symfony cache, install fixtures or whatever, to do this, check your container name from running containers list, connect to your container, and execute your command
docker ps
docker exec -ti lekode.lab.php sh
php bin/console ...
First, many thanks for your contributions, please note that this eco system is a personal preference that I use in most of my PHP projects (using Symfony or other frameworks), if you find any typo/misconfiguration, or just want to optimize more the workflow, please
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
TODO: Write history
This project is licensed under the MIT License - see the LICENSE file for details