About

The PHP Code Quality Project is a collection of ANT/Phing Tasks to integrate certain build tools.

Keep your app stable

Integrate phpunit, phpspec, ... to keep your code free from bug and vulnerability.

Be clean and bloodless

Integrate phpcs, phpmd, ... to keep your code free from mess and blood.

Integrate build tools

PHPCQ support a lot of tools e.g. phpunit, phpmd, phploc, phpcpd … more are on their way!

Easy to setup, easy to run

Install through composer, runs with ANT or Phing.

Runs everywhere!

Like your local machine, your Gitlab CI or any hosted CI like Travis.

QuickStart

Installing

PHPCQ can be installed with a set of recommended tasks or with a custom selection of tasks.

You need to install and setup composer first!

$ composer require --dev phpcq/all-tasks

This installs the following tools for you:

Thats all! You can now continue configure you build.

You need to install and setup composer first!

$ composer require --dev phpcq/phpcq

Now install the build tools you want to use.

$ composer require --dev phpcq/author-validation
$ composer require --dev phpcq/autoload-validation
$ composer require --dev phpcq/branch-alias-validation
$ composer require --dev phpcq/coding-standard
$ composer require --dev phpcq/travis-configuration-check
$ composer require --dev pdepend/pdepend
$ composer require --dev phpunit/phpunit
$ composer require --dev sebastian/phpcpd
$ composer require --dev phploc/phploc
$ composer require --dev phpmd/phpmd
$ composer require --dev phpspec/phpspec

Thats all! You can now continue configure you build.


Configuring

Create a build.xml in the root of your project.

<?xml version="1.0" encoding="UTF-8"?>
<project name="my-project" default="build" description="Automated build of my project">
    <!-- import the main tasks -->
    <import file="vendor/phpcq/phpcq/phpcq.main.xml" />
</project>

Thats all! You can now continue running your build.

Import the vendor/phpcq/phpcq/phpcq.main.xml in your build.xml, then call the verify and/or analyse target.

<?xml version="1.0" encoding="UTF-8"?>
<project name="my-project" default="run" description="My project runner">
    <!-- import the main tasks -->
    <import file="vendor/phpcq/phpcq/phpcq.main.xml" />

    <target name="run"
            depends="verify, analyse">
        <!-- the verify target runs all validations,
             the analyse target runs all analyses -->

        ...
    </target>
</project>

Thats all! You can now continue running your build.

Import the vendor/phpcq/phpcq/phpcq.main.xml in your build.xml, then call the phpcq tasks you like.

<?xml version="1.0" encoding="UTF-8"?>
<project name="my-project" default="run" description="My project runner">
    <!-- import the main tasks -->
    <import file="vendor/phpcq/phpcq/phpcq.main.xml" />

    <target name="run"
            depends="
                phplint,
                composer-validate,
                autoload-validation,
                author-validation,
                phploc,
                pdepend,
                phpmd,
                phpcs,
                phpcpd,
                phpunit,
                phpspec,
                branch-alias-validation,
                travis-configuration-check
            ">
        <!-- remove the tasks you don't want to be executed -->

        ...
    </target>
</project>

Thats all! You can now continue running your build.


Running

First of all, you need to install ANT. Most distributions and CI services comes with a package or preinstalled version of ANT. If ANT is installed, you can run your build with:

$ ant -keep-going

Thats all! You can now continue running your build.

The Phing support is very experimental and may not work as expected, sorry ☹

First of all, you need to install phing:

$ composer require --dev phing/phing

Now you can run your build with:

$ ./vendor/bin/phing -keep-going

Tasks