A simple archive that provides a development and production container for Symfony applications based on Docker. Uses FrankenPHP, MariaDB, phpMyAdmin and Mailpit. Node.js is also supported and a basic Visual Studio Code customization is included.
- Download the latest release and unzip the archive.
- Open Visual Studio Code and reopen the project in the Dev Container.
- Download the Symfony Skeleton:
curl -O https://raw.githubusercontent.com/symfony/skeleton/refs/heads/7.1/composer.json
- Add Dev Container extensions dependencies:
composer require --dev --no-update friendsofphp/php-cs-fixer phpstan/phpstan
- If you plan to use Docker in production, add FrankenPHP runtime:
composer require --no-update runtime/frankenphp-symfony
- Install Symfony:
composer install
Important
PHPStan will fail if the tests
folder is missing and you haven't installed either the webapp
or symfony/test-pack
packages. To resolve this, you can either install these packages or modify the phpstan.dist.neon
configuration file.
Note
Composer version cannot be changed at the moment and is locked to the latest version.
Various versions can be set by changing the compose.yaml
file:
# compose.yaml
services:
php:
build:
args:
# Set the FrankenPHP version (default latest).
# Supports any FrankenPHP Docker tag.
FRANKENPHP_TAG: php8.3
# Set the Node.js version (default empty, meaning not installed).
# Supports a major version or keywords "current" and "lts".
NODE_VERSION: lts
db:
# Set the MariaDB version (default latest).
# Supports any MariaDB Docker tag.
image: mariadb:11
phpmyadmin:
# Set the phpMyAdmin version (default latest).
# Supports any phpMyAdmin Docker tag.
image: phpmyadmin:5
Other configuration files:
config/docker/php*.ini
for PHPconfig/docker/supervisor.conf
for Supervisor
Note
The app
database is automatically created and can be accessed by the app
user using the password !ChangeMe!
. The same password is also assigned to the root
user.
Available endpoints are:
URL | Service |
---|---|
https://localhost | App |
localhost:3306 | MariaDB |
http://localhost:8080 | phpMyAdmin |
http://localhost:8025 | Mailpit |
Visual Studio Code extensions installed and configured by default:
- PHP
- Git History
- EditorConfig
- PHP CS Fixer
- DotENV
- PHPUnit Test Explorer
- JSON Schema Store Catalog
- PHPStan
Create the .env.prod.local
file to set up the environment for all containers:
Important
In production, all environment files are ignored except for .env.prod.local
. The .env
file will only be used to generate the .env.local.php
file.
# The domain name, HTTPS certificate is installed automatically
SERVER_NAME="example.com"
# The timezone used by all containers
TZ="Europe/Rome"
# Symfony container variables
DATABASE_URL="mysql://$MARIADB_USER:$MARIADB_PASSWORD@db:3306/$MARIADB_DATABASE?charset=utf8"
# MariaDB container variables
MARIADB_DATABASE="app"
MARIADB_USER="app"
MARIADB_PASSWORD="MySecretPassword"
MARIADB_ROOT_PASSWORD="MySecretRootPassword"
To run the project in production, execute docker compose up -d
. FrankenPHP worker mode is enabled by default. Doctrine migrations are automatically executed if available.
All kinds of contributions are welcome and appreciated. See the contributing guidelines, the community looks forward to your contributions!
Released under the terms of the ISC License.