惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
B
Blog RSS Feed
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
量子位
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
L
LangChain Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园_首页
IT之家
IT之家
V
Visual Studio Blog
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
宝玉的分享
宝玉的分享
Apple Machine Learning Research
Apple Machine Learning Research
I
InfoQ
D
Docker
V
V2EX

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Dockerized Symfony 6.4 project boilerplate
Nicolas Bonn · 2026-05-08 · via DEV Community

Nicolas Bonnici

> Repository and post updated September 22 2024

The perfect Dockerized Symfony 6.4 boilerplate doesn't exists... But wait, what if I create and share my own vision of it?!!

Leggooo

We gonna build a classic stack that i personaly love, with such cutting edge technologies like PostgreSQL 16, Redis and Nginx HTTP server and also PHP 8.3 and FPM and Symfony framwork in LTS version 6.4.

First of all, I want something really easy to use, so let's leverage docker compose plugin without any extra argument to start and initialize all needed containers.

composer setup

Enter fullscreen mode Exit fullscreen mode

Project treeview

  • logs
  • docker
  • symfony

Everything is at project root to do so, no fancy parameter needed since everything use default project path convention.

Simply 3 folders, the first one "docker/" to store all Docker related configurations, one other "logs/" for the whole containers logs and a "symfony/" last one directory to put your Symfony project's source code.

Go further

Good but wait I have other developers to sync in that project and do they can scaffold it on their local development env without knowing any clue about Symfony and server side development or never work on containerized projects?

Nope just kidding, ain't no voodoo involved in that process, we're not gonna reinvent the wheel and make a revolution. Not at all, just a simple leverage of composer and more specially his scripts section.

Ok if you don't rage quit this post or punch directly your screen you'll enjoy a little magic, with this simple one line command to run all needed containers then setup the database, create the data model before populating it if you agree the prompt by responding "yes" at the end.

All that using one dead simple command:

composer setup

Enter fullscreen mode Exit fullscreen mode

Explanation we first build and launch all needed containers, the run them in demon mode, this the first part of the command: docker compose up --build -d. The second part will then run the "install-project" composer script. See the symfony/composer.json "scripts" section.

{
    "scripts": {
        ...
        "setup": [
            "composer run up",
            "composer run deps:install",
            "composer run database",
            "composer run migrate",
            "composer run fixtures"
        ],
        "up": [
            "docker compose --env-file symfony/.env up -d --build"
        ],
        "down": [
            "docker compose --env-file symfony/.env down"
        ],
        "stop": [
            "docker compose --env-file symfony/.env stop"
        ],
        "build": [
            "docker compose --env-file symfony/.env build"
        ],
        "deps:install": [
            "docker exec -it php-fpm bin/composer install -o"
        ],
        "database": [
            "docker exec -it php-fpm bin/console doctrine:database:create -n --if-not-exists",
            "docker exec -it php-fpm bin/console doctrine:database:create -n --if-not-exists --env=test"
        ],
        "migrate": [
            "docker exec -it php-fpm bin/console doctrine:migration:migrate -n",
            "docker exec -it php-fpm bin/console doctrine:migration:migrate -n --env=test"
        ],
        "fixtures": [
            "docker exec -it php-fpm bin/console doctrine:fixtures:load -n",
            "docker exec -it php-fpm bin/console doctrine:fixtures:load -n --env=test"
        ],
        "tests": [
            "docker exec -t php-fpm bash -c 'clear && ./vendor/bin/phpunit --testdox --exclude=smoke'"
        ],
        "lint": [
            "docker exec -t php-fpm ./vendor/bin/php-cs-fixer ./src/"
        ],
        "lint:fix": [
            "docker exec -t php-fpm ./vendor/bin/php-cs-fixer fix ./src/"
        ],
        "db": [
            "psql postgresql://postgres:password@127.0.0.1:15432/dbtest"
        ],
        "logs": [
            "docker compose logs -f"
        ],
        "cache-clear": [
            "docker exec -t php-fpm bin/console c:c"
        ]
    }
}

Enter fullscreen mode Exit fullscreen mode

It will first install all needed composer dependencies and optimize classes autoloader. Then execute migrations up to the latest version then populate database with fixtures respectively with "doctrine/doctrine-migrations-bundle" and "doctrine/doctrine-fixtures-bundle" bundles.

The actual composer scripts available:

composer [
    setup
    up
    stop
    build
    deps:install
    database
    migrate
    fixtures
    tests: launch phpunit tests suite
    lint
    db: connect to database container via CLI client 
    logs: show containers logs
    cache-clear
]

Enter fullscreen mode Exit fullscreen mode

Talk is cheap, show me the code

Linus Torvalds famous quote: Talk is cheap, show me the code

> Feel free to fork, contribute and maintain this boilerplate using this Gitlab repository: nicolasbonnici/symfony-docker-boilerplate