This is a basic stack for create y running Symfony project into Docker containers. Here are the docker-compose built images:
nginx
, acting as the webserver v1.21.php
, the PHP-FPM container with the 8.1 version of PHP. Xdebug is available by default.mysql
which is the MySQL database container with a MySQL 8.0 image.
Project (/var/www/)
βββ docker
β βββ mysql
β βββ nginx
β βββ php
βββ app
βββ .. all symfony content
- Clone this repository.
- (Optional) Customize your local domain by editing the variable
NGINX_SERVER_NAME
indocker/.env
before running the setup. - From the project root, run:
This script will:
chmod +x setup.sh ./setup.sh
- Build and start all containers.
- If
/app
is empty, it will create a new Symfony project automatically. - Set correct permissions for the
var
directory.
- Clone this repository.
- Go inside folder
/docker
. - Edit environment variables in
.env
file- The value of the variable
NGINX_SERVER_NAME
is theserver_name
used in NGINX.
- The value of the variable
- Build/run containers.
docker-compose build docker-compose up -d
- You should work inside the
php
container.docker-compose exec php bash
- Check requirements for a Symfony application
you will see the following output in the terminal
symfony check:requirements
[OK] Your system is ready to run Symfony projects
- Create a new Symfony project
Your Symfony project will be installed in
symfony new .
/app
folder. Now you can access it from the browser through the domain that you have specified in theNGINX_SERVER_NAME
variable of the.env
file.
Now you should have your Symfony project started and accessible from the domain you have configured in NGINX_SERVER_NAME
.
Remember that this domain must be pointing to your localhost.
Available by default. Configure /docker/php/xdebug.ini
- In case you want to deactivate it:
xdebug.mode=off
- In case you need debug only requests with IDE KEY: PHPSTORM from frontend in your browser:
xdebug.start_with_request = no
xdebug.idekey=PHPSTORM
- In case you need debug any request to an api (by default):
xdebug.start_with_request = yes