# Tools: phpMetrics

I’m researching some tools to visualize PHP code which I think can be helpful to understand the complexity of a project.
In this article I explore a tool called phpMetrics that is a static analysis tool for php. It can collect information about PHP files in your project.

This tool can be installed via composer as a standalone tool.

composer global require 'phpmetrics/phpmetrics'
phpmetrics --report-html=myreport.html /path/of/your/sources


When the tool is installed you can run it from the composer global directory. It starts with analysing all the PHP files and collecting metrics and generating everything that is needed.

vagrant@seoeffect:/var/www/html\$ /home/vagrant/.composer/vendor/bin/phpmetrics --report-html=myreport.html /var/www/seoeffect
PHPMetrics by Jean-François Lépine

795/1853 [============>---------------]  42%


There are a lot of numerical metrics collected like the cyclomatic complexity, number of lines, number of classes etc.. For an overview of all metrics the documentation should be consulted. These metrics can be quite useful for a global overview about how well your code is doing and where the possible problems in your code are. All these metrics are drawn into graphs that give a quick overview about the state of a project.

When the analyzing is done there is one html file generated with an overview of the metrics. For this project there are a lot of red circles so there is a lot of work to do.

On