This project installs Symfony and provides a Docker Compose environment to be development ready in a few quick steps.
This project also relies on Makefiles to ease the developer everyday tasks.
Create the project
$ composer create-project boulzy/symfony-skeleton && cd $_
This will install Symfony the same way the official installer do, alongside a
docker directory containing all its
needed to build a Docker Compose development environment.
Setup Docker Compose environment (optional)
Docker Compose uses environment variables stored in
docker/.env. This file can contain sensitive data and should be in
$ cd docker && make .env && cd .. # OR $ php docker/scripts/env.php
The environment file will be created with the
docker.env.distdefault values if this step is skipped.
Available environment variables are:
APP_PATH: this is the absolute path to the root directory of your Symfony project. It is used to mount volumes.
NGINX_IMAGE: the image name of the nginx service
NGINX_CONTAINER: the container name of the nginx service
NGINX_VERSION: the version to use for the nginx image (available versions are on the official repository)
NGINX_HTTP_PORT: the host port to use for HTTP requests to the nginx server
NGINX_HTTPS_PORT: the host port to use for HTTPS requests to the nginx server
PHPFPM_IMAGE: the image name of the php-fpm service
PHPFPM_CONTAINER: the container name of the php-fpm service
PHPFPM_VERSION: the version to use for the php-fpm image (available versions are on the official repository, it must be a php-fpm version)
Install the project
$ make install # OR $ cd docker $ docker-compose pull --quiet --ignore-pull-failures $ docker-compose build --pull --force-rm $ docker-compose run --rm php-fpm composer install $ cd ..
The Docker Compose environment is composed of a nginx HTTP server, relying on a php-fpm service that is also used as the shell from where php commands should be executed.
The following command is used to start the services:
$ make start OR $ cd docker $ docker-compose up -d
The Symfony application is now available on
https://localhost. The port used might change according to the environment
The web server is configured to use SSL, using a self-signed certificate.
For shell commands, the php-fpm service is provided with Composer and PHPUnit.
# Enter into a shell session $ make shell # OR $ cd docker && docker-compose exec php-fpm ash # Run a single command $ cd docker && docker-compose exec php-fpm bin/console c:c
To stop the environment:
$ make stop OR $ cd docker $ docker-compose stop
Tip: The command
docker-compose exec php-fpmcan be aliased for less typing.
The main Makefile (
./Makefile) has a default help command listing all available commands:
$ make #OR $ make help
The Docker Compose environment should grow with the project infrastructure dependencies. The Docker Compose documentation is a good start to learn more about it.