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.5+ - 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:
dbanddb_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/testResponse:
{
"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-emailGET /api/test-notifyGET /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-accessResponse:
{
"message": "User access rights successfully calculated"
}GET /api/users/{locationId}Response:
{
"users": [...],
"message": "Users found"
}GET /api/config/listResponse:
[
{
"id": 1,
"name": "app_name",
"value": "Symfony Demo",
"author": {...}
}
]POST http://localhost:8000/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"
}
}DELETE http://localhost:8000/api/config/{id}Response:
{
"message": "Конфигурация успешно удалена"
}| Status Code | Description | Response |
|---|---|---|
422 Unprocessable Entity |
Invalid UUID format | json {"error": true, "message": "Ошибка валидации данных", "details": {"violations": {"id": "Некорректный формат ID конфигурации"}}} |
404 Not Found |
Configuration not found | json {"message": "Конфигурация с указанным ID не найдена"} |
403 Forbidden |
Access denied | Unauthorized access |
GET /api/log/listResponse:
{
"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 benchtests/
├── 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