Skip to content

Repository files navigation

PHP Framework Comparison

Compare static analysis and code quality metrics of popular PHP frameworks.

Frameworks Analyzed

Metrics Collected

ToolDescription
PHPStan (Level 8)Static analysis error count
PsalmStatic analysis error count
phplocLines of code, classes, methods, complexity
Cognitive ComplexityMethod complexity analysis
Silenced IssuesInline suppressions and baseline entries

Requirements

  • PHP 8.1+
  • Composer
  • Git

Getting Started

# Clone the repo
git clone https://github.com/php-collective/framework-comparison.git
cd framework-comparison
# Install dependencies
composer install
# Run all checks (first run clones frameworks - takes a while)
php run_all.php

Usage

# Run all analyses
php run_all.php
# Or run individual checks
php check_phpstan/run_all.php
php check_psalm/run_all.php
php check_phploc/run_all.php
php check_cognitive/run_all.php
php check_silenced/run_all.php
# Regenerate report from existing JSON
php generate_report.php

Configuration

Framework settings are defined in config.php:

'laravel' => [
'repo' => 'laravel/framework',
'branch' => '11.x', // null = default branch'srcDir' => 'src',
],
  • branch: Set to analyze a specific branch (e.g., 11.x for stable vs master for dev)
  • srcDir: Directory containing source code to analyze
  • Laminas packages each have their own branch setting

To switch between dev/stable branches, edit config.php and delete the repos/ directory to re-clone.

Results

See reports/README.md for the latest comparison table.

Note: The results are not interpreted here, only displayed as raw data so far.

Out of Scope

This comparison focuses solely on static code analysis metrics. The following are explicitly not covered:

  • Performance benchmarks - Runtime speed, memory usage, request throughput
  • Feature comparisons - ORM capabilities, routing, templating, etc.
  • Security audits - Vulnerability assessments, CVE history
  • Documentation quality - Completeness, clarity, examples
  • Community & ecosystem - Package availability, job market, support
  • Learning curve - Ease of onboarding, developer experience
  • Test coverage - Unit/integration test percentages
  • API stability - Breaking changes between versions

TODOs

  • visible results as table or graph

Other ideas:

CategoryIdea
More metricsTest coverage %, dependency count
NormalizationErrors per class, errors per method
BreakdownPHPStan/Psalm errors by category (type safety, unused code, etc.)
AutomationGitHub Actions to re-run monthly
Trend trackingStore historical data to show improvement over versions

About

Compare some metrics of popular PHP frameworks

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages