- php:8.1.6-fpm
- nginx:1.21.6-alpine
- mysql:8.0.29
- redis:7.0.0-alpine
- swaggerapi/swagger-ui:v4.11.1
- mailhog/mailhog:v1.0.1
- docker
- docker-compose
- git
- Clone this repository to your local machine and go inside:
git clone https://github.com/shpran/docker-stack && cd docker-stack
- Create an
app
directory:Further you can store your symfony project inside thismkdir app
app
folder. - Make a copy of
.env.example
file and name it.env
:cp .env.example .env
- Configure all environment variables in
.env
file - Install mkcert
- Execute the following command to generate certificates:
./scripts/gencerts.sh
- Create a network:
docker network create [PROJECT_NAME]
- Build and run docker containers:
docker compose build && docker compose up -d
- Open
hosts
file and add new host127.0.0.1 [PROJECT_NAME].docker.loc
. For example:127.0.0.1 test.docker.loc
- Now you can open
https://[PROJECT_NAME].docker.loc:[NGINX_SSL_PORT]
in your browser.
Variable | Example | Default |
---|---|---|
CONTAINER_PREFIX | local | - |
PROJECT_NAME | test | - |
TIMEZONE | Europe/Minsk | - |
GITHUB_USER | user | - |
GITHUB_TOKEN | token | - |
GITHUB_EMAIL | test@test.com | - |
GITHUB_NAME | "Name Surname" | - |
XDEBUG_CLIENT_HOST | 192.168.100.1 | - |
NGINX_PORT | 10080 | 80 |
NGINX_SSL_PORT | 10443 | 443 |
MYSQL_ROOT_PASSWORD | root | root |
MYSQL_USER | dev | dev |
MYSQL_PASSWORD | dev | dev |
MYSQL_DATABASE | dev | dev |
MYSQL_PORT | 13306 | 3306 |
MAILHOG_PORT | 18025 | 8025 |
SMTP_PORT | 11025 | 1025 |
SMTP_HOSTNAME | mailhog.example | mailhog.example |
SWAGGER_API_URL | https://test.docker.loc:10443/api.yaml | - |
SWAGGER_PORT | 17000 | 7000 |
Use the following command to access your containers:
docker compose exec [container] [bash|sh]
or this command, if you are trying to access containers outside the docker-project directory:
docker exec -it [CONTATINER_PREFIX]_[container] [bash|sh]
The functionality only gets activated when a specific trigger is present when the request starts.
The name of the trigger is XDEBUG_TRIGGER
, and Xdebug checks for its presence in either $_ENV
(environment variable),
$_GET
or $_POST
variable, or $_COOKIE
(HTTP cookie name).
Also, you can set environment variable directly on the server:
export XDEBUG_TRIGGER=1
Or remove it:
unset XDEBUG_TRIGGER
The recommended way to initiate a debugging session is by configuring your IDE to accept incoming debugging
connections, and then use a browser extension which sets the right trigger cookie.
The extensions are:
- Xdebug Helper for Firefox (source).
- Xdebug Helper for Chrome (source).
- XDebugToggle for Safari (source).
Each extension adds an icon to your browser where you can select which functionality you want to trigger.
Xdebug will continue to start debugging for every request as long as the debug toggle has been enabled.
To access it go to http://localhost:[SWAGGER_PORT]
.