This project contains a complete Symfony 7+ backend running in Docker with:
- PHP 8.3
- PostgreSQL
- Nginx
- MailHog
- pgAdmin
- Automatic Composer install
- Entrypoint with caching and permissions fixes
- JWT Auth
- DTO architecture
- RabbitMQ
- Redis caching
- N+1 query optimizations
- Swagger / OpenAPI documentation
- Clone the project:
git clone <repo>
cd symfony- Copy environment file:
cp app/.env.example app/.env- Start Docker environment:
docker-compose up -d --build- Install backend dependencies (if needed):
docker exec -it symfony_app composer install| Service | URL |
|---|---|
| API (Nginx) | http://localhost:8080 |
| MailHog | http://localhost:8025 |
| pgAdmin | http://localhost:8081 |
| Redis | localhost:6379 |
| PostgreSQL | localhost:5432 |
symfony/
assets/
bin/
config/
docker/
php/
Dockerfile
php.ini
entrypoint.sh
nginx/
nginx.conf
public/
src/
templates/
tests/
.env
.env.example
composer.json
docker-compose.yml
docker-compose.prod.yml
README.md
docker exec -it symfony_app bashsymfony console cache:clear
symfony console doctrine:migrations:migratedocker-compose restartdocker exec -it symfony_app ./vendor/bin/phpunitThe project uses the LexikJWTAuthenticationBundle, which requires generating a key pair:
- private key: config/jwt/private.pem
- public key: config/jwt/public.pem
The keys are not in the repository; they must be generated locally.
Run in the project directory:
mkdir -p config/jwt
php bin/console lexik:jwt:generate-keypairDefault Configuration:
- algorithm: RSA (RS256)
- length: 4096 bits
- key Location: config/jwt/
If you receive errors indicating that OpenSSL is not installed, ensure that the extension is enabled in PHP.
If you need to generate new keys:
rm config/jwt/*.pem
php bin/console lexik:jwt:generate-keypair --overwriteThis project supports production-ready deployment using:
- docker-compose.prod.yml
- Nginx + PHP-FPM
- Supervisor (workers)
- GitHub Actions workflow (optional)
Includes:
- Build image
- Push to registry
- Deploy via SSH or CI runner
- Uses DTO Request/Response classes for strong typing.
- All prices stored as string for precision.
- Redis handles:
- product caching
- order caching (optional)
- N+1 queries fixed with
joinand optimized repositories. - JWT Auth with token TTL and refresh tokens.
- Centralized API response formatter.
- Swagger auto-generated with OpenAPI attributes.
Below are suggested future improvements:
- API Platform integration layer
- Webhooks (payment providers)
- OAuth2 for third‑party integrations
- AI endpoint (/api/analyze-text)
- Message queue (RabbitMQ / Kafka)
- Full test coverage for checkout and payments
docker exec -it symfony_app composer installdocker exec -it symfony_app symfony console cache:cleardocker-compose down -vMIT