Understand Your
PHP Codebase.
Architecture, maintainability, structural health — 60+ metrics across files, classes, and methods, for the PHP projects you actually have to maintain long-term.
composer require --dev php-code-archeology/php-code-archeology
MIT License · PHP 8.2–8.5 · Composer · No extensions required
Everything your codebase needs
measured and reported.
60+ Architecture Metrics
Cyclomatic complexity, cognitive complexity, maintainability index, LCOM, Halstead metrics, instability, coupling, type coverage — measured per file, class, method, and function. The HTML report includes a full glossary with formulas, thresholds, and interpretation guidelines.
14 Problem Detectors
God classes, too-complex methods, dead code, circular dependencies, deep inheritance trees — automatically flagged with error/warning/info severity and actionable descriptions.
6 Report Formats
One analysis. Six outputs. Interactive HTML dashboard, Markdown for wikis, JSON for CI pipelines, SARIF for GitHub Code Scanning, AI-optimised summary, and Knowledge Graph for graph databases.
Test Coverage Integration
Auto-detects PHPUnit, Pest, and Codeception. Maps test files to production classes by namespace and naming convention. Ingests Clover XML for line-level coverage data alongside architecture metrics.
Framework-Aware Analysis
Reads your composer.json to detect Symfony, Laravel, and Doctrine — then adjusts metric thresholds and exclusion rules automatically. No false positives from framework boilerplate.
Not just another linter.
Static analysis tools measure complexity. PhpCodeArcheology understands architecture.
Talk to your codebase.
PhpCodeArcheology ships with a built-in MCP (Model Context Protocol) server. Connect it to Claude, Cursor, or any MCP-compatible client and query your architecture with natural language — hotspots, dependency graphs, health scores, refactoring priorities.
PhpCodeArcheology is the first PHP static analysis tool with native MCP support.
The tool also generates a CLAUDE.md — a structured project overview your AI coding assistant can read before touching the codebase. Because the AI should probably know what it's working with.
Your codebase as a graph.
Export your entire codebase as a graph — classes as nodes, dependencies as edges. Import into Neo4j, Obsidian, or your own tooling. Spot architectural clusters, dead zones, and coupling hotspots visually.
Find your untested hotspots.
Auto-detects PHPUnit, Pest, and Codeception. Maps test files to production classes by namespace and naming convention. Feed in a Clover XML file and get line-level coverage overlaid on architecture metrics — so you know which complex, high-coupling classes have no test coverage.
| Class | Coverage | Tests |
|---|---|---|
| UserService | 94% | 12 tests |
| OrderProcessor | 67% | 8 tests |
| PaymentService | 0% | — |
| InvoiceGenerator | 51% | 4 tests |
| AuthMiddleware | 88% | 6 tests |
Knows what it's looking at.
Reads your composer.json to detect Symfony, Laravel, and Doctrine — then adjusts metric thresholds and exclusion rules automatically.
Find the hot zones.
Classes that change constantly and score high on complexity are your real maintenance risks. Cross-reference commit frequency with architecture metrics to surface the files that demand the most attention — before they become emergencies.
| Class | Commits | WMC | Risk |
|---|---|---|---|
| OrderService | 47 | 38 | HIGH |
| UserRepository | 31 | 22 | MED |
| PaymentGateway | 28 | 19 | MED |
| EventDispatcher | 12 | 8 | LOW |
One number. The whole picture.
The Health Score distills complexity, coupling, cohesion, test coverage, and churn into a single 0–100 score — so you can answer "how healthy is this codebase?" without a spreadsheet. Track it over time to validate that refactoring efforts are actually working.
Save a snapshot. Compare later.
Track metric drift over time. Save a baseline after a cleanup sprint and run it again in a month to see exactly what changed.
Two runs. Side by side.
Run the analysis on two branches or two points in time and get a structured diff of every metric that changed.
Up and running in minutes.
composer require --dev php-code-archeology/php-code-archeology
php vendor/bin/phpcodearcheology src/
Output: tmp/report/html/
php vendor/bin/phpcodearcheology --quick src/