Skip to content

Simtel/symfony-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Symfony Demo Project

PHP Version Symfony Version PHPStan Level License

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.

πŸ“‹ Table of Contents

✨ Features

  • 🐳 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

πŸ› οΈ Technology Stack

Backend Framework

  • Symfony 7 - The leading PHP framework for web applications
  • PHP 8.4+ - Latest PHP version with modern features

Database & ORM

Code Quality & Analysis

Testing & Performance

  • PHPUnit - Unit and feature testing framework
  • PHPBench - Performance benchmarking

Development & Deployment

  • Docker - Containerization platform
  • Docker Compose - Multi-container application management
  • Adminer - Database management interface
  • Make - Build automation tool

Messaging & Communication

πŸ›οΈ Architecture

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

Design Patterns Used

  • 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

πŸ“‹ Requirements

  • Docker 20.10+
  • Docker Compose 2.0+
  • Make (for automation)
  • Git (for version control)

πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/Simtel/symfony-project.git
cd symfony-project

2. Build and Start Containers

# Build Docker containers
make build

# Start the application
make up

3. Database Setup

  1. Open Adminer at http://localhost:8080
  2. Create databases: db and db_test

4. Install Dependencies and Run Migrations

# Install Composer packages
make composer-install

# Run database migrations
make migrate

5. Verify Installation

# Run tests to ensure everything works
make test

# Check API endpoint
curl http://localhost:8000/api/test

πŸ”§ Development

Available Make Commands

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

Development Workflow

  1. Start Development Environment

    make up
    make cli  # Enter container for development
  2. Make Changes

    • Edit code in your preferred IDE
    • Follow PSR-12 coding standards
    • Write tests for new features
  3. Quality Checks

    make phpstan  # Static analysis
    make pint     # Code formatting
    make test     # Run tests
  4. Database Changes

    make to-migration  # Generate migration
    make migrate       # Apply migration

πŸ“‘ API Documentation

The project provides a comprehensive REST API for managing users, configurations, logs, and various testing functions.

Base URL

http://localhost:8000/api

Authentication

Some endpoints require authentication via API key.

Core Endpoints

Health Check

GET /api/test

Response:

{
  "test": true,
  "time": "2025-08-29T10:30:00+00:00",
  "message": "API is working correctly"
}

Request Mapping Test

POST /api/test-map-request
Content-Type: application/json

{
  "name": "test",
  "value": "example"
}

Email Testing

GET /api/test-email

Notification Testing

GET /api/test-notify

User Management

Get User Information

GET /api/user/{id}

Response:

{
  "id": 1,
  "name": "John Doe",
  "email": "john@example.com",
  "locations": [...],
  "contacts": [...]
}

Find User by Name

GET /api/user/find/{userName}

Add Location to User

PUT /api/user/{userId}/location/{locationId}

Response:

{
  "message": "Location successfully added to user"
}

Calculate User Access

POST /api/user/{userId}/calculate-access

Response:

{
  "message": "User access rights successfully calculated"
}

Get Users by Location

GET /api/users/{locationId}

Response:

{
  "users": [...],
  "message": "Users found"
}

Configuration Management

List Configurations

GET /api/config/list

Response:

[
  {
    "id": 1,
    "name": "app_name",
    "value": "Symfony Demo",
    "author": {...}
  }
]

Create Configuration

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"
  }
}

Log Management

List Logs

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 Log Details

GET /api/log/{id}

Response:

{
  "log": {
    "id": 1,
    "action": "user_created",
    "data": {...},
    "author": {...},
    "createdAt": "2025-08-29T10:30:00+00:00"
  }
}

HTTP Status Codes

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

Error Format

All errors are returned in the following format:

{
  "error": "Error description",
  "code": 400,
  "details": {
    "field": "Field error details"
  }
}

Usage Examples

Create Configuration with curl

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"}'

Get User Information

curl -X GET http://localhost:8000/api/user/1 \
  -H "Authorization: Bearer YOUR_API_KEY"

πŸ§ͺ Testing

The project includes comprehensive testing capabilities:

Test Types

  • Unit Tests - Testing individual components in isolation
  • Feature Tests - Testing complete features and API endpoints
  • Performance Tests - Benchmarking critical operations

Running Tests

# 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

Test Structure

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

🎯 Code Quality

This project maintains high code quality through automated tools:

Static Analysis

# Run PHPStan at maximum level
make phpstan

Code Formatting

# Fix code style issues
make pint

Architecture Analysis

# Check dependency rules
vendor/bin/deptrac analyze

Quality Gates

  • βœ… PHPStan Level MAX compliance
  • βœ… PSR-12 coding standards
  • βœ… 100% test coverage for critical paths
  • βœ… No circular dependencies
  • βœ… Clean architecture boundaries

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/amazing-feature
  3. Make your changes
    • Follow coding standards
    • Add tests for new features
    • Update documentation
  4. Run quality checks
    make phpstan
    make pint
    make test
  5. Commit your changes
    git commit -m 'Add amazing feature'
  6. Push to the branch
    git push origin feature/amazing-feature
  7. Open a Pull Request

Development Guidelines

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published