A Symfony 4.2 skeleton based on the official Symfony skeleton with a Docker Compose development environment

symfony, php, Skeleton, docker, symfony-skeleton


Symfony Skeleton

This project installs Symfony and provides a Docker Compose environment to be development ready in a few quick steps.


The use of this Symfony installer requires Composer and Docker Compose version 3 or higher.

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 the .gitignore file.

    $ cd docker && make .env && cd ..

# OR

    $ php docker/scripts/env.php

The environment file will be created with the docker.env.dist default 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

    $ cd docker
    $ docker-compose up -d

The Symfony application is now available on https://localhost. The port used might change according to the environment variables defined.

HTTP server

The web server is configured to use SSL, using a self-signed certificate.

Shell usage

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

    $ cd docker
    $ docker-compose stop

Tip: The command docker-compose exec php-fpm can be aliased for less typing.


The main Makefile (./Makefile) has a default help command listing all available commands:

    $ make


    $ make help

Next steps

The Docker Compose environment should grow with the project infrastructure dependencies. The Docker Compose documentation is a good start to learn more about it.