A modern benchmarking framework for PHP testing performance across versions 5.6 to 8.5
Features β’ Installation β’ Usage β’ Architecture β’ Contributing
|
|
|
|
|
|
| Requirement | Version | Purpose |
|---|---|---|
| Docker | Latest | Container runtime |
| Docker Compose | v2+ | Multi-container orchestration |
| Make | Any | Task automation (optional) |
git clone https://github.com/jblairy/php-benchmark.git
cd php-benchmark
make up # Start Docker containers
make db.refresh # Create database and load benchmark fixturesThe make db.refresh command will:
- Create the MariaDB database
- Run migrations to create tables
- Load 100+ benchmark definitions from YAML fixtures
# Run all benchmarks
make run
# View results in browser
open http://localhost/dashboardRun Specific Benchmark
# Run a specific test
make run test=Loop
# Run with custom iterations
make run test=Loop iterations=100
# Run on specific PHP version
docker-compose run --rm main php bin/console benchmark:run \
--test=Loop \
--php-version=php84 \
--iterations=10Development Commands
# Database management
make db.reset # Drop and recreate database (empty)
make db.refresh # Reset database + load fixtures
make fixtures # Load benchmark fixtures only
# Testing
make test # Run all PHPUnit tests (50 tests, 212 assertions)
make test-coverage # Run tests with coverage report
# Code Quality
make phpstan # Static analysis (level max)
make phpcsfixer # Check code style (PSR-12)
make phpcsfixer-fix # Fix code style automatically
make quality # Run all quality checks
# Assets (CSS/JS)
make assets.refresh # Rebuild and refresh frontend assets
# Translations (i18n)
make trans.compile # Compile YAML β XLF (2-3x faster, production-ready)
make trans.update # Extract new keys from templates + compileAccess the web dashboard to explore benchmark results:
- URL:
http://localhost/dashboard - Features: Interactive charts, live progress tracking, detailed statistics
This project follows Clean Architecture principles with Domain-Driven Design (DDD) and Hexagonal Architecture (Ports & Adapters).
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Infrastructure β
β (Symfony, Doctrine, Docker, Web, CLI, Persistence) β
β β β
β Application β
β (Use Cases, Orchestration) β
β β β
β Domain β
β (Business Logic - Pure PHP) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
src/
βββ Domain/ # π― Core Business Logic (Framework-free)
β βββ Benchmark/ # Benchmark models, value objects, ports
β βββ Dashboard/ # Dashboard domain models, statistics
β βββ PhpVersion/ # PHP version enumeration
β
βββ Application/ # π¦ Use Cases (Orchestration Layer)
β βββ UseCase/ # Benchmark execution orchestration
β βββ Dashboard/ # Dashboard data aggregation
β
βββ Infrastructure/ # π§ Technical Implementation
βββ Async/ # Event dispatcher and message bus adapters
βββ Cli/ # Symfony Console commands
βββ Execution/ # Docker script execution
βββ Persistence/ # Doctrine entities, repositories, fixtures
βββ Web/ # Symfony controllers, components, Twig
- β Dependencies flow inward: Infrastructure β Application β Domain
- β Domain is framework-agnostic: Pure PHP, no Symfony/Doctrine dependencies
- β Ports & Adapters: Domain defines interfaces (Ports), Infrastructure implements them (Adapters)
- β Validated by PHPArkitect: Architecture rules are enforced automatically
| Document | Description |
|---|---|
| docs/architecture/01-overview.md | Architecture deep dive |
| docs/architecture/02-layers.md | Layer responsibilities |
| docs/architecture/03-ports-adapters.md | Hexagonal architecture details |
| AGENTS.md | Developer reference guide |
| docs/README.md | Complete documentation index |
We love contributions! Whether it's bug fixes, new benchmarks, or documentation improvements, all contributions are welcome.
| π | Code Style | Follow PSR-12 standards (enforced by PHP-CS-Fixer) |
| π | Static Analysis | Pass PHPStan level max (strictest level) |
| ποΈ | Architecture | Respect Clean Architecture principles (validated by PHPArkitect) |
| β | Testing | Write PHPUnit tests for new features |
| π | Language | Write all code, comments, docs, commits, PRs in English |
| π | Documentation | Document your benchmarks and architectural decisions |
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run quality checks:
make quality - Run tests:
make test - Commit your changes (see Atomic Commits Guide)
- Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Run all quality checks before committing
make quality
# This runs:
# β PHPStan (static analysis)
# β PHP-CS-Fixer (code style)
# β PHPUnit (tests)
# β PHPMD (mess detection)
# β PHPArkitect (architecture validation)- AGENTS.md - Complete developer reference guide
- docs/guides/creating-benchmarks.md - How to add benchmarks
- docs/guides/atomic-commits.md - Commit best practices
- docs/architecture/ - Architecture documentation
Benchmarks are defined as YAML files in fixtures/benchmarks/. No PHP code changes needed!
Click to see example benchmark
# fixtures/benchmarks/my-benchmark.yaml
slug: my-benchmark
name: 'My Custom Benchmark'
category: 'Custom'
description: 'Description of what this benchmark tests'
icon: π
tags:
- custom
- performance
phpVersions:
- php84
- php85
code: |
// Your benchmark code here
$result = [];
for ($i = 0; $i < 10000; $i++) {
$result[] = $i * 2;
}Load the new benchmark:
make fixtures # Load fixtures only
# or
make db.refresh # Reset database + reload all benchmarksπ Full guide: docs/guides/creating-benchmarks.md
|
PHP 8.4+ |
Symfony 7.2 |
Doctrine ORM |
Docker |
|
MariaDB |
Chart.js |
Stimulus |
| Tool | Purpose | Level/Standard |
|---|---|---|
| PHPStan | Static analysis | Level max (strictest) |
| PHP-CS-Fixer | Code style | PSR-12 + Symfony |
| PHPUnit | Unit testing | 50 tests, 212 assertions |
| PHPArkitect | Architecture validation | Clean Architecture rules |
| PHPMD | Mess detection | Custom ruleset |
| Infection | Mutation testing | Available |
- π― Benchmarks: 107 automated tests
- β Tests: 50 passing (212 assertions)
- π Code Quality: PHPStan level max, PSR-12 compliant
- ποΈ Architecture: Clean Architecture + DDD + Hexagonal
- π PHP Versions: Supports 5.6 to 8.5
- π Documentation: 15+ detailed guides and ADRs
This project is licensed under the MIT License. See the LICENSE file for details.
- PHP Community - For continuous inspiration and improvements
- Contributors - Thank you to everyone who has contributed to this project
- Open Source Projects - Built on the shoulders of giants
Special thanks to the maintainers of:
- Symfony - The PHP framework
- Doctrine - Database ORM
- Symfony Messenger - Asynchronous processing
- PHPStan - Static analysis
| π Issues | Report bugs or request features |
| π¬ Discussions | Ask questions and share ideas |
| π§ Contact | Reach out via GitHub issues or discussions |
If this project helped you, please consider:
- β Star this repository on GitHub
- π Fork and contribute
- π’ Share with the PHP community
- π‘ Open issues for improvements