One point we know need more love and atenttion at DrupalConsole project is to increase the test coverage. Even when I had some previous experience using tools like PHPUnit and Behat. I decided to start researching for material related to this topic and how to automate test execution.

On this research I found this blog post Write your git hooks in PHP and keep them under git control and this resource of PHP QA related tools The PHP Quality Assurance Toolchain that I highly recomend you to read and visit.

PHPQA a new project was born

After trying to include a variation of the code I found on the blog post mentioned above, you can see code at CodeQualityTool.php. I decided to decouple this feature and publish an advanced version of this on a separated project.

You can find the source code at github https://github.com/jmolivas/phpqa/ because you know, we all love Open Source.

Project Overview

This project aims to serve as a CLI tool to make easy the use of different PHP tools related to Quality Assurance and code analysis in PHP.

Every analyzer tool handles arguments and options using different formats, the goal of this project is to provide a single way to interact with those projects, you can also set options and arguments using a default configuration file when the project supports it.

Available Analyzers

Install

Cloning the project

$ git clone git@github.com:jmolivas/phpqa.git $ cd phpqa # download dependencies $ composer install # make phpqa globally accessible creating a symlink $ ln -s /path/to/phpqa/bin/phpqa /usr/local/bin/phpqa

Usage

Copy configuration files to user home directory

$ cd to/project/path $ phpqa init --project=PROJECT --global --override

Option Description project Available values `php`, `symfony` and `drupal`. global Copy configuration files to user home directory, instead of current working directory. override If this option is set, files are copied using override flag.

Option global does not accept a value must be set as --global.

Option override does not accept a value must be set as --override.

Analyze a project

$ cd to/project/path $ phpqa analyze --project=PROJECT --files=FILES $ phpqa analyze --project=PROJECT --git

Option Description project Available values php, symfony and drupal files Files or directories to analyze. git If this option is set, all files added to git index will be scanned. This is useful when setting executing this tool on a pre-commit git-hook.

Option git does not accept a value must be set as --git.

Options files and git can not used in combination.

Option project could be omitted if a phpqa.yml or phpqa.yml.dist file is available at current working directory.

If you like to know about nice to have features, please visit the project page https://github.com/jmolivas/phpqa#nice-to-have-features

This is just the beginning of the project the real goal is to provide a tool to take advantage of all those great projects and make easy to customize and execute.

This project was built to be fully customizable. I will be working on the documentation related to override default configurations, but in the meantime please please visit https://github.com/jmolivas/phpqa#override-configuration and give a try and as usual, comments and suggestions are more than welcome.

NOTE: Image used on this bog post, originally from xkcd comic Quality Code at https://xkcd.com/1513/

**NOTES:****NOTES:**