Open-source project
phpmetrics/PhpMetrics avatar
phpmetrics/PhpMetrics

phpmetrics: a release rewrites five files by regex, and the compatibility check lints with PHP 5.6

Beautiful and understandable static analysis tool for PHP

2,619 stars261 forksPHPMIT

At a glance

What is it?
PhpMetrics reports PHP project and class metrics as an HTML page, and its readme is 153 words long. Everything interesting is in the build files instead: a compatibility target that parses the source with a five year old PHP, a tag target that patches version strings into issue templates and packaging metadata, and a docker target that builds from a directory the repository does not have.
Who is it for?
This fits a PHP team that wants a readable metrics page in CI without adopting a static analyser that fails the build, and the honest scope is a report rather than a gate: the quick start produces an HTML file, and continuous integration rules are something you configure rather than something it enforces. Two things to know before you wire it in.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 86 days ago.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • phpmetrics/PhpMetrics2,619 ★ · +1
Star history
Repository2026-10-042026-11-15
phpmetrics/PhpMetrics2.6k2.6k

1 Stars in the last 42 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The compatibility check parses the source with PHP 5.6, minus one file

One Makefile target defines the supported syntax floor, and it does it with a container:

code
(docker run --rm -v `pwd`:/www --workdir=/www  php:5.6-cli find src -iname "*.php" -exec php -l {} \; |grep -v "Php7NodeTraverser.php" | grep -v "No syntax errors detected") && echo OK

The target runs a lint pass over every PHP file under src inside a php:5.6-cli image and prints OK when nothing but the expected clean output comes back. Two filters decide what counts as a pass. One discards the file named Php7NodeTraverser.php, which is the single exception allowed to use newer syntax. The other discards the parser's own confirmation line. So the codebase as a whole parses under an interpreter old enough to predate most of PHP 7, which is a stronger compatibility claim than the container image makes, since that image is built on php:8.4. The unit test target is separate and simply excludes a group of tests named binary.

A release patches the version into five files with two substitutions

The tag target is the release process, and it is written as text substitution rather than as a version source. It first runs a check-tag target that validates the TAG variable against a pattern for a vX.Y.Z version with an optional alpha, beta or rc suffix, and fails loudly with the expected format in the message when it does not match. It then substitutes the tag into the two GitHub issue templates, the debian control file, a bintray metadata file and the installation document, and separately rewrites the date pattern inside that bintray file with the current date. A second substitution exists for a different reason, noted in a comment: a function returns the version to the user without the v prefix, so that string gets its own replacement. The version therefore lives in at least five places, and the only thing keeping them aligned is this pair of regular expressions at release time.

The docker target builds from a directory the repository does not have

Two targets at the bottom of the same file concern containers, and one of them names a build context that does not appear among the top level entries. The root holds a Dockerfile, a dockerignore file, a Makefile, a homebrew formula directory, a releases directory with the packaged artifact, directories for artifacts, build, bin, templates, tests, tooling, documentation and source, a composer manifest, a phpunit configuration, a php-cs-fixer configuration, a rector configuration, a craft configuration, two configuration examples and an editor configuration. There is no directory named a. The docker target builds an image tagged for releasing from that context path, so as written it cannot run against a clean checkout of this repository unless that path is created first. The phony list at the top of the file names three targets, docker, build and check-tag, while the file itself also defines test, compatibility and tag.

The image ships a compiled phar and installs git for a single option

The container is thin by design and the reasons are written down. It starts from php:8.4 and copies one file into the binary directory, the phar from the releases directory, then makes it executable. The apt layer that follows installs git alone, and the comment above it says why: so the option that needs version control can be used. There is no composer step and no dependency install in the image, because everything is already inside the phar. A volume is declared for the application directory, which is also the working directory, the entrypoint is the tool itself, and the default command asks for the version, so starting the image with no arguments prints a version string and exits. The image label credits a different person from the one named as the author on the project page.

Two configuration files sit at the root and the page names neither

The quick start is three steps: add the package as a development dependency, run the binary from the vendor directory with a report flag and a folder to analyse, then open the generated index.html file in a browser. Underneath that there is a mention of a configuration file for customising the report, adding options and configuring rules for continuous integration, and a documentation link for it. The root of the repository carries two candidates, a JSON example file and a YAML file. Nothing on the page says which one the tool reads, whether both are accepted, or whether the YAML file is configuration at all, and the example JSON is the only one named as an example. Anyone automating this has to determine the format from the documentation site rather than from the repository.

Composer, a phar, a brew formula, a debian package and an image

The distribution surface is much wider than the readme suggests, and the release history shows how unevenly it moves. The newest tags are v2.11.0 on 2026-08-09 and v2.10.0 on 2026-07-21, which are three weeks apart, and before those v2.9.0 on 2025-07-07, a gap of about a year. The main branch last received a push on 2026-08-21, twelve days after the newest tag, and the repository is not archived. Alongside the composer package there is a packaged phar for the container to copy, a homebrew formula directory, a debian control file patched at release time, a bintray metadata file, and a changelog. The project also states plainly that it is built and maintained on free time, and asks for stars and sponsorship to fund maintenance and new metrics.

Editorial conclusion

This fits a PHP team that wants a readable metrics page in CI without adopting a static analyser that fails the build, and the honest scope is a report rather than a gate: the quick start produces an HTML file, and continuous integration rules are something you configure rather than something it enforces. Two things to know before you wire it in. The compatibility target parses the source with PHP 5.6 while excluding one file, so the supported syntax floor is set by that exclusion, not by anything the readme says. And the version lives in five files that a release rewrites with regular expressions, which means a fork or a vendored copy has no single place to bump, so check the function in src/functions.php and the installation doc agree with your tag.

Frequently asked questions

What is PhpMetrics?

It is a static analysis tool that produces metrics about a PHP project and its classes as a readable HTML report. It is MIT licensed, installed as a Composer development dependency, and run from the vendor directory.

How do I generate an HTML report with PhpMetrics?

Run php ./vendor/bin/phpmetrics --report-html=myreport with the folder to analyse, then open the generated myreport/index.html file. Running the same binary with --metrics prints the available metric list.

Which PHP versions does PhpMetrics support?

The container image is built FROM php:8.4, while a Makefile compatibility target lints every file under src inside a php:5.6-cli image, filtering out one file named Php7NodeTraverser.php. That exclusion is what sets the real syntax floor for the rest of the source.

Can PhpMetrics be configured?

Yes, through a configuration file used to customise the report, add options and configure rules for continuous integration. The repository root carries both a JSON example and a YAML file, and the project page refers to a configuration file without saying which of the two the tool reads.

What metrics does PhpMetrics compute?

The metric list is not in the repository readme. It is kept in the documentation site and can be printed by running the binary with the --metrics flag, which is the route to take rather than guessing from the tool name.

Official sources

  1. License: MIT
  2. phpmetrics/PhpMetrics on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/phpmetrics-phpmetrics.svg)](https://hysenlabs.com/projects/phpmetrics-phpmetrics)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/phpmetrics-phpmetrics.svg)](https://hysenlabs.com/projects/phpmetrics-phpmetrics)

Was this useful?