This is a starter kit for Symfony 7.1 with the following technologies:
- Docker
- Docker Compose
- PHP 8.2
- Nginx
- Adminer
- PostgreSQL
- MailHog
- Xdebug
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/yourusername/symfony-starter-kit.git cd symfony-starter-kit
-
Create environment variables:
cp .env.dist .env
-
Build and start the containers:
docker-compose up --build -d
-
Install Symfony dependencies:
docker-compose exec php composer install
- PHP 8.2: The PHP version used for the application.
- Nginx: Serves the Symfony application.
- PostgreSQL: The database server.
- Adminer: Database management tool accessible at http://localhost:8080.
- MailHog: Email testing tool accessible at http://localhost:8025.
Here is the docker-compose.yml
configuration:
version: '4.2'
services:
php-fpm:
container_name: php
build:
context: .
dockerfile: docker/php/Dockerfile
volumes:
- ./symfony:/var/www/html/symfony
- ./docker/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- ./docker/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini
networks:
- starter-kit
nginx:
container_name: nginx
image: nginx:stable
ports:
- '80:80'
volumes:
- ./symfony:/var/www/html/symfony
- ./docker/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
networks:
- starter-kit
db:
container_name: postgres
image: postgres
restart: always
shm_size: 128mb
environment:
POSTGRES_PASSWORD: secret
ports:
- '5432:5432'
volumes:
- ./docker/db/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- starter-kit
command: postgres -c 'max_connections=200'
adminer:
container_name: adminer
image: adminer
restart: always
environment:
ADMINER_DEFAULT_DB_HOST: database
ADMINER_DESIGN: haeckel
ADMINER_PLUGINS: tables-filter tinymce
ports:
- '54320:8080'
networks:
- starter-kit
mailhog:
container_name: mailhog
image: mailhog/mailhog:latest
restart: always
ports:
- 1025:1025
- 8025:8025
networks:
- starter-kit
networks:
starter-kit:
driver: bridge
Add GrumPHP to your Symfony project using Composer:
docker-compose exec php composer require --dev phpro/grumphp
Create a grumphp.yml
file in the root of your project:
grumphp:
tasks:
phpcs:
standard:
- 'PSR12'
phpstan:
autoload_file: ~
configuration: ~
level: null
force_patterns: []
ignore_patterns: []
triggered_by: ['php']
memory_limit: "-1"
use_grumphp_paths: true
Add the GrumPHP configuration to your composer.json
scripts section to automatically run GrumPHP on git commit
:
"scripts": {
"post-install-cmd": [
"vendor/bin/grumphp git:init"
],
"post-update-cmd": [
"vendor/bin/grumphp git:init"
]
}
Run the following command to initialize GrumPHP:
php vendor/bin/grumphp git:init
Update the .env
file with your database credentials:
DATABASE_URL=postgresql://symfony:symfony@postgres:5432/symfony
- Symfony application: http://localhost:8000
- Adminer: http://localhost:8080
- MailHog: http://localhost:8025
This project is licensed under the MIT License.