halleck45/php-metrics
PhpMetrics analyzes PHP projects and classes, producing a readable HTML report packed with code metrics like cyclomatic complexity, maintainability index, and coupling. Install it as a dev dependency via Composer and run it against any folder to spot risky code and track quality over time.
Architecture fit. PhpMetrics is a CLI-first static analysis tool, not a library. It installs as a Composer --dev dependency, walks a source tree with a PHP parser, computes class/file/project-level metrics (cyclomatic complexity, Halstead, maintainability index, CRAP, LCOM, coupling, comment ratio), and emits a self-contained HTML report plus JSON/XML/CSV variants. That means it has zero runtime footprint in production — no autoload surface, no framework coupling, no service registration. For a Laravel codebase it is architecturally inert: it reads source files and writes artifacts. The "0 dependents" signal is expected and benign; the package is a terminal node in the dependency graph, so there is no downstream coupling risk and no blast radius beyond CI.
Integration feasibility. High. Integration is a single Composer dev requirement plus one CI step invoking vendor/bin/phpmetrics --report-html=build/metrics app/. The HTML report is a static file, which makes it trivially archivable as a CI artifact or publishable to Pages/S3. Configuration is a YAML file (.phpmetrics.yml) with --config, allowing exclude rules for vendor/, generated code, and migrations. The main feasibility question is not "can we run it" but "can we enforce it" — the tool is oriented toward visual reporting, so build-breaking thresholds require either the violations report output or parsing the JSON/XML in a wrapper script. Confirm this before promising a quality gate.
Technical risk. Low-to-moderate, and entirely contained in CI:
memory_limit and possibly shard by directory (via groups) for a monorepo.halleck45/php-metrics) differs from the Composer package to install (phpmetrics/phpmetrics). Pin explicitly; verify the release cadence and changelog for breaking changes to report formats.Key questions. Which PHP minor versions are in scope, and does the current release parse them? Are we willing to run this alongside existing analysers, or does it need to displace one? Who owns threshold calibration? Do we need per-PR gating or is a weekly trend report sufficient? What is the CI runtime budget for a full-tree scan? Is the HTML artifact published, and to whom?
Stack fit. Strong for a Laravel/PHP shop. It is a first-class Composer citizen, installs into the existing require-dev block, and requires no new runtime (no Node, no Java, no database) — a meaningful advantage over SonarQube or other platform-grade tools. The HTML output is genuinely legible to non-engineers, which makes it usable in engineering-health reviews and tech-debt conversations, not just as a developer utility. For Laravel specifically, the exclude list matters more than usual: storage/, bootstrap/cache/, generated migrations, and IDE helper stubs should be excluded so the report reflects authored code.
Migration path. Additive, with no migration. Treat it as a net-new capability: add the dev dependency, generate a baseline report against main, and use that baseline as the reference point. The only "migration" is cultural — moving from ad hoc code-review intuition about complexity to a measured, tracked number. That argues for a report-only phase of at least one sprint before any gating.
Compatibility. Dev-only dependency, so no conflict with production constraints except PHP version resolution — Composer will refuse the install if the CLI tool's PHP floor exceeds the project's. Run composer require --dev in a branch and inspect the lockfile diff; if it drags in transitive upgrades, that is the moment to stop and reconsider. Report formats (JSON/XML schema) should be treated as a contract if you write a parser around them; pin the major version.
Sequencing.
Maintenance. Very low. No runtime to patch, no infrastructure, no data store. The recurring cost is (a) bumping the dev dependency and (b) re-tuning excludes when the repo layout changes. Budget roughly a few hours per quarter. The real maintenance burden is threshold ownership — without a named owner, the gate drifts into either permanently red or permanently ignored.
Support. MIT license, active release cadence, documented, with a sponsorship-backed single-maintainer model. Single-maintainer is the notable risk: if upstream stalls, your mitigation is cheap — it is a dev tool, so you can pin, fork, or drop it. This is fundamentally different from a runtime library risk. No vendor SLA, no commercial support tier; internal teams must own first-line triage.
Scaling. Analysis time and memory grow with codebase size; memory is the binding constraint, not CPU. For a large monorepo, expect to shard by directory or package and aggregate reports, or restrict scanning to changed paths on PRs with a full weekly scan. CI concurrency matters: a heavyweight analysis job on every PR will contend with test suites, so schedule the full scan nightly and a scoped scan per PR. Artifact storage also accumulates — expire reports aggressively.
Failure modes to design for.
Ramp-up. Roughly half a day for one engineer to reach productive use; the HTML report is self-explanatory, so developer onboarding is near-zero and adoption friction is genuinely low. The non-trivial learning curve is interpretation: knowing which metrics predict defects in your codebase and which are noise. Plan for one engineer to own metric literacy (half a day of reading plus two calibration cycles) and to run a short session with the team on what the report is and is not telling them. Realistic time-to-first-useful-signal: one sprint; time-to-trusted-gate: one quarter.
How can I help you explore Laravel packages today?