A modern, Docker-based Symfony 7 demo project designed for scalable PHP application development with strong emphasis on code quality, testing, and CI/CD readiness.
- Features
- Technology Stack
- Architecture
- Requirements
- Quick Start
- Development
- API Documentation
- Testing
- Code Quality
- Contributing
- π³ Dockerized Environment - Complete containerized development setup
- ποΈ Modern Architecture - Domain-Driven Design with clean separation of concerns
- π Static Analysis - PHPStan at maximum level for bulletproof code
- π¨ Code Formatting - Laravel Pint for consistent code style
- π Architecture Analysis - Deptrac for dependency rule enforcement
- π§ͺ Comprehensive Testing - Unit, feature, and performance tests
- π CI/CD Ready - GitHub Actions and GitVerse integration
- π‘ REST API - Full-featured API with authentication
- π§ Email & Notifications - Built-in mailing and notification system
- π οΈ Developer Tools - Makefile automation and Xdebug support
- Symfony 7 - The leading PHP framework for web applications
- PHP 8.4+ - Latest PHP version with modern features
- Doctrine ORM - Object-relational mapping for PHP
- Doctrine Migrations - Database schema versioning
- MySQL - Reliable relational database
- PHPStan - Static analysis tool (Level: MAX)
- Laravel Pint - Code style fixer
- Deptrac - Dependency rule analysis
- Rector - Automated code refactoring
- Docker - Containerization platform
- Docker Compose - Multi-container application management
- Adminer - Database management interface
- Make - Build automation tool
- Symfony Messenger - Message handling and queues
- Symfony Mailer - Email sending capabilities
- Symfony Notifier - Multi-channel notifications
The project follows Domain-Driven Design (DDD) principles with a modular monolith approach:
src/
βββ Context/
β βββ Common/ # Shared functionality
β β βββ Application/ # Use cases and DTOs
β β βββ Domain/ # Business logic and entities
β β βββ Infrastructure/ # Controllers, repositories, external services
β βββ User/ # User management context
β βββ Project/ # Project-specific features
βββ DataFixtures/ # Database seeders
βββ Kernel.php # Application kernel
- Repository Pattern - Data access abstraction
- Command Pattern - Encapsulated requests
- Service Layer - Business logic encapsulation
- Event-Driven Architecture - Loose coupling via events
- CQRS - Command Query Responsibility Segregation
- Docker 20.10+
- Docker Compose 2.0+
- Make (for automation)
- Git (for version control)
git clone https://github.com/Simtel/symfony-project.git
cd symfony-project
# Build Docker containers
make build
# Start the application
make up
- Open Adminer at http://localhost:8080
- Create databases:
db
anddb_test
# Install Composer packages
make composer-install
# Run database migrations
make migrate
# Run tests to ensure everything works
make test
# Check API endpoint
curl http://localhost:8000/api/test
Command | Description |
---|---|
make build |
Build Docker containers |
make up |
Start containers |
make down |
Stop containers |
make cli |
Enter PHP container |
make xcli |
Enter PHP container with Xdebug |
make composer-install |
Install Composer dependencies |
make migrate |
Run database migrations |
make rollback |
Rollback last migration |
make to-migration |
Generate new migration |
make test |
Run all tests |
make testf FILTER=TestName |
Run filtered tests |
make phpstan |
Run static analysis |
make pint |
Fix code style |
make bench |
Run performance benchmarks |
-
Start Development Environment
make up make cli # Enter container for development
-
Make Changes
- Edit code in your preferred IDE
- Follow PSR-12 coding standards
- Write tests for new features
-
Quality Checks
make phpstan # Static analysis make pint # Code formatting make test # Run tests
-
Database Changes
make to-migration # Generate migration make migrate # Apply migration
The project provides a comprehensive REST API for managing users, configurations, logs, and various testing functions.
http://localhost:8000/api
Some endpoints require authentication via API key.
GET /api/test
Response:
{
"test": true,
"time": "2025-08-29T10:30:00+00:00",
"message": "API is working correctly"
}
POST /api/test-map-request
Content-Type: application/json
{
"name": "test",
"value": "example"
}
GET /api/test-email
GET /api/test-notify
GET /api/user/{id}
Response:
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"locations": [...],
"contacts": [...]
}
GET /api/user/find/{userName}
PUT /api/user/{userId}/location/{locationId}
Response:
{
"message": "Location successfully added to user"
}
POST /api/user/{userId}/calculate-access
Response:
{
"message": "User access rights successfully calculated"
}
GET /api/users/{locationId}
Response:
{
"users": [...],
"message": "Users found"
}
GET /api/config/list
Response:
[
{
"id": 1,
"name": "app_name",
"value": "Symfony Demo",
"author": {...}
}
]
POST /api/config
Content-Type: application/json
{
"name": "setting_name",
"value": "setting_value"
}
Response:
{
"message": "Configuration successfully created",
"config": {
"id": 2,
"name": "setting_name",
"value": "setting_value"
}
}
GET /api/log/list
Response:
{
"logs": [
{
"id": 1,
"user": "John Doe",
"action": "user_created",
"createdAt": "2025-08-29 10:30:00",
"url": "/api/log/1"
}
]
}
GET /api/log/{id}
Response:
{
"log": {
"id": 1,
"action": "user_created",
"data": {...},
"author": {...},
"createdAt": "2025-08-29T10:30:00+00:00"
}
}
Code | Description |
---|---|
200 OK |
Successful request |
201 Created |
Resource successfully created |
400 Bad Request |
Data validation error |
401 Unauthorized |
Authentication required |
404 Not Found |
Resource not found |
500 Internal Server Error |
Internal server error |
All errors are returned in the following format:
{
"error": "Error description",
"code": 400,
"details": {
"field": "Field error details"
}
}
curl -X POST http://localhost:8000/api/config \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"name": "debug_mode", "value": "true"}'
curl -X GET http://localhost:8000/api/user/1 \
-H "Authorization: Bearer YOUR_API_KEY"
The project includes comprehensive testing capabilities:
- Unit Tests - Testing individual components in isolation
- Feature Tests - Testing complete features and API endpoints
- Performance Tests - Benchmarking critical operations
# Run all tests
make test
# Run specific test file
make testf FILTER=ConfigTest
# Run tests with coverage (inside container)
bin/phpunit --coverage-html coverage
# Run benchmarks
make bench
tests/
βββ Bench/ # Performance benchmarks
βββ Command/ # CLI command tests
βββ Feature/ # Feature/integration tests
βββ Unit/Context/ # Unit tests organized by context
βββ *.php # Test helpers and base classes
This project maintains high code quality through automated tools:
# Run PHPStan at maximum level
make phpstan
# Fix code style issues
make pint
# Check dependency rules
vendor/bin/deptrac analyze
- β PHPStan Level MAX compliance
- β PSR-12 coding standards
- β 100% test coverage for critical paths
- β No circular dependencies
- β Clean architecture boundaries
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes
- Follow coding standards
- Add tests for new features
- Update documentation
- Run quality checks
make phpstan make pint make test
- Commit your changes
git commit -m 'Add amazing feature'
- Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
- Follow Domain-Driven Design principles
- Write meaningful test cases
- Keep controllers thin, services focused
- Use type hints and return types
- Document complex business logic
- Maintain backward compatibility
Built with β€οΈ using Symfony 7 and modern PHP practices