Writing Quality Code and Code Analysis

Beside writing tests, there are more factors that affect the quality of your code. Let’s check some tools for PHP that can improve your code quality.

PhpMetrics

PhpMetrics

PhpMetrics is a very convenient static analysis tool for your code and your PHP projects.

It can be installed with Composer or by downloading phar:

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

PhpMetrics can even interact with Jenkins and Sonar.

After running PhpMetrics from terminal you get an HTML file that looks something like this:

PhpMetrics Report

Some examples of PhpMetrics reports:

Resources

Other useful tools to check out:

  • PHP Parser - This is a PHP 5.2 to PHP 7.1 parser written in PHP. Its purpose is to simplify static code analysis and manipulation.
  • PHP QA tools - List of PHP Quality Assurance tools
  • Jenkins PHP - Template for Jenkins Jobs for PHP Projects
  • PHP Mess Detector - User friendly and easy to configure frontend for the raw metrics measured by PHP Depend
  • PHPCheckStyle - open-source tool that helps PHP programmers adhere to certain coding conventions
  • Qafoo Quality Analyzer - Tool helping us to analyze software projects.
GitHub OctocatFound a typo? Something wrong with this content? Just fork and edit it.

Content of this work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. Code snippets in examples are published under the CC0 1.0 Universal (CC0 1.0). Thanks to all the contributors.