generated from Websites/symfony-template
main
Symfony Template
Symfony 7.2 Projekttemplate mit Podman-Containern für Entwicklung und Produktion.
Stack
| Komponente | Version |
|---|---|
| PHP-FPM | 8.4 |
| Symfony | 8.1 |
| Nginx | 1.27 |
| Redis | 8 |
Dev-Abhängigkeiten: Symfony Profiler, MakerBundle, DebugBundle, VarDumper, Xdebug
Voraussetzungen
- Podman
openssl(für Secret-Generierung)
Entwicklungsumgebung
./setup-dev.sh
Das Skript:
- Erstellt
.env.localmit generiertemAPP_SECRET - Baut die Container-Images (
symfony-php,symfony-nginx) - Startet den Pod
symfony-devmit PHP-FPM, Nginx und Redis - Führt
composer installaus
Umgebung verwalten
# Stoppen / Starten
podman pod stop symfony-dev
podman pod start symfony-dev
# Entfernen
podman pod stop symfony-dev && podman pod rm symfony-dev
# Neustart (rebuild)
./setup-dev.sh
Im Container arbeiten
# Shell öffnen
podman exec -it symfony-php bash
# Symfony CLI
podman exec -it symfony-php php bin/console <befehl>
podman exec -it symfony-php php bin/console make:controller HomeController
# Composer
podman exec -it symfony-php composer require <paket>
Xdebug
Xdebug ist im Dev-Container aktiv und wird per Trigger gestartet (kein automatischer Start).
| Einstellung | Wert |
|---|---|
| Modus | debug |
| Port | 9003 |
| Host | host.containers.internal |
| Trigger | XDEBUG_SESSION (Cookie/Query-Parameter) |
Produktions-Build
In der Live-Umgebung wird nur der PHP-FPM-Container benötigt. Das Produktions-Image enthält die gesamte App inkl. Vendor-Verzeichnis – kein Volume-Mount erforderlich.
# Image bauen
./build-prod.sh symfony-app 1.0.0
# Container starten
podman run -d \
--name symfony-app \
-p 9000:9000 \
-e APP_ENV=prod \
-e APP_SECRET=$(openssl rand -hex 16) \
-e REDIS_URL=redis://your-redis-host:6379 \
symfony-app:1.0.0
# Cache warmup
podman exec symfony-app php bin/console cache:warmup --env=prod
Der Build verwendet einen Multi-Stage-Build:
- Stage 1: Composer installiert nur Produktionsabhängigkeiten (
--no-dev --optimize-autoloader) - Stage 2: Schlankes PHP-FPM Image mit optimiertem OPcache
Projektstruktur
.
├── build-prod.sh # Produktions-Image bauen
├── setup-dev.sh # Entwicklungsumgebung starten
├── composer.json
├── public/
│ └── index.php # Symfony-Einstiegspunkt
├── src/
│ └── Kernel.php
├── config/
│ ├── bundles.php
│ ├── routes.yaml
│ ├── services.yaml
│ └── packages/
│ ├── cache.yaml # Redis als Cache-Backend
│ ├── framework.yaml
│ └── routing.yaml
└── podman/
├── php/ # Entwicklungs-Container
│ ├── Containerfile
│ └── conf.d/dev.ini # Xdebug & Error-Reporting
├── nginx/
│ ├── Containerfile
│ └── default.conf
└── php-prod/ # Produktions-Container
├── Containerfile
└── conf.d/opcache.ini
Umgebungsvariablen
| Variable | Beschreibung | Standard |
|---|---|---|
APP_ENV |
Symfony-Umgebung | dev |
APP_DEBUG |
Debug-Modus | true |
APP_SECRET |
Kryptografisches Secret | Wird in .env.local generiert |
REDIS_URL |
Redis-Verbindungs-URL | redis://localhost:6379 |
.env enthält sichere Standardwerte und wird eingecheckt. Lokale Überschreibungen in .env.local (nicht eingecheckt).
Lizenz
GPL-3.0-only
Languages
PHP
59.2%
SCSS
18.7%
Twig
7.2%
Shell
4.9%
CSS
3.8%
Other
6.2%