PhpMetrics is a free, open source monitoring & observability project written in PHP and released under MIT. It has 2,616 GitHub stars, 261 forks and 4 open issues, and was last pushed 2 months ago. On this registry it ranks #148 of 270 tracked projects in Monitoring & Observability, with 5 head-to-head comparisons available.

What is PhpMetrics?

PhpMetrics is an MIT-licensed static analysis tool for PHP, distributed through Composer as phpmetrics/phpmetrics, that computes metrics about a PHP project and its classes and renders them as an HTML report for developers, tech leads, and CI pipelines that need visible code-quality data.

What it is

PhpMetrics is a static analyzer that lives in the PHP and Composer ecosystem. It reads a PHP codebase and produces metrics about the project as a whole and about individual classes, then writes those metrics into an HTML report that the README describes as "beautiful and readable." The tool ships as a Composer package and runs as a command-line binary, so it fits the same install-and-run workflow that PHP projects already use for their other development dependencies. Its homepage hosts the documentation site, including a quick start guide, a configuration reference, and a detailed list of the metrics it calculates.

The concrete problem it solves is turning raw quality signals into something a team can actually read. Instead of assembling bespoke parsing scripts or reading analyzer output line by line in a terminal, a developer runs one command and gets a browsable report written to a directory on disk. The README also exposes php ./vendor/bin/phpmetrics --metrics, which lists the metrics the tool provides, so the set of measurements is discoverable from the command line rather than only from the documentation. Because the analysis is static, it does not need the application to boot, serve traffic, or connect to a database in order to report on the code.

Key capabilities

  • Collects metrics about a PHP project and about its classes, per the README description of what the tool reports.
  • Generates an HTML report to a chosen output directory with --report-html=myreport, browsable at ./myreport/index.html.
  • Lists every available metric from the CLI with php ./vendor/bin/phpmetrics --metrics.
  • Supports a configuration file to customize the report, add options, and configure rules for Continuous Integration.
  • Integrates with CI workflows, reflected in the ci topic and in the README's reference to configuring CI rules.
  • Installs as a development dependency with composer require phpmetrics/phpmetrics --dev.
  • Runs as an executable at ./vendor/bin/phpmetrics after installation.

Who uses it and how

  • PHP teams that run it inside a continuous integration pipeline, where the configuration file defines the rules the build enforces.
  • Developers who install it as a dev dependency and run it locally against a folder before opening a pull request.
  • Reviewers and tech leads who read the generated HTML report instead of asking for a walkthrough of a diff.
  • Projects that need class-level quality data without granting the analyzer runtime access to production systems, since the analysis is static.
  • Maintainers who keep the tool's output in a CI job artifact so the report can be inspected after a build finishes.

Getting started

Install the package as a development dependency with composer require phpmetrics/phpmetrics --dev, then generate a report with php ./vendor/bin/phpmetrics --report-html=myreport and open ./myreport/index.html in a browser. The quick start guide on the project website covers the same path.

How it compares

No paid products or competing tools are named in the supplied facts, so there is nothing to contrast on licence, hosting model, or cost. On the evidence available, PhpMetrics stands alone in this registry.

When to use it — and when not to

A self-hoster needs a working PHP runtime and Composer, because the tool installs and runs through Composer and emits a static HTML report rather than operating a hosted service; no database, storage layer, or mail server is mentioned as a requirement. It is a poor fit for anyone who needs runtime profiling or production traffic analysis, since it is a static analyzer and never executes the code it measures. It is also a poor fit for teams that want a fully self-contained repository README, because the facts show a short README that points most substantive documentation, including the metric list and configuration reference, at the external website. The maintainer states that the project is built and maintained in free time and asks for sponsorship to fund maintenance and new metrics, so feature pace depends on volunteer effort rather than a funded roadmap.

project readme (upstream, from github) — read inline

PhpMetrics

Packagist Downloads License Latest Stable Version

Standard report

PhpMetrics

PhpMetrics provides metrics about PHP project and classes, with beautiful and readable HTML report.

Documentation | Twitter | Contributing



Quick start

Follow the quick start guide to get started.

# install the package as a dev dependency
composer require phpmetrics/phpmetrics --dev

# run PHPMetrics to analyze a folder and generate a report
php ./vendor/bin/phpmetrics --report-html=myreport <folder-to-analyze>

Then open the generated ./myreport/index.html file in your browser.

You can use a configuration file to customize the report, add options, configure rules for Continuous Integration, etc.

Metrics

You'll find detailed list of metrics in documentation, or running php ./vendor/bin/phpmetrics --metrics

Author

  • Jean-François Lépine

License

See the LICENSE file.

Contributing

See the CONTRIBUTING file.

Support the project

PHPMetrics is built and maintained on free time. If it saved you some of yours:

  • ⭐ Star the repository. It costs nothing and it is how most developers discover the tool.
  • ❤️ Become a sponsor. Sponsorship directly funds maintenance time and the addition of new features and metrics.

Frequently asked questions

Is PhpMetrics free to use?

PhpMetrics is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does PhpMetrics do?

Beautiful and understandable static analysis tool for PHP

What is PhpMetrics written in?

PhpMetrics is primarily written in PHP. Its source is publicly available at https://github.com/phpmetrics/PhpMetrics, and it has 2,616 GitHub stars.