Skip to content

PHPCS

PHPCS is a tool that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard.

Installation

You can use PHPCS on continuousphp by installing it via composer. Simply add it to your composer.json and update your composer.lock by running a composer update.

"require-dev": {
  "squizlabs/php_codesniffer": "~2.5.0"
}

Configuration

When you create a new pipeline, continuousphp will attempt to configure the tests automatically by looking for phpcs.xml files in your repository. The found configuration files will then be listed in the second step of the pipeline configuration. Of course, you can always modify or delete the configuration proposed by continuousphp. As for all other testing frameworks on continuousphp, you can choose if the tests with PHPCS will block the deployment on failure or if the build goes into a warning state if the tests fail.

Keep in mind that PHPCS does a static analysis of your code. So PHPCS will only run on one of your chosen PHP versions.

IMPORTANT:

You don't need to run PHPCS using a shell command or a Phing target. continuousphp takes care of starting the tests for you.

PHPCS configuration

Executing tasks

You can specify tasks to be executed before running the tests. This can be very useful to initialize external resources like databases or third-party services. Currently continuousphp supports Phing, but others will be supported soon (shell commands, ...).

IMPORTANT:

Tasks can be defined at different places in your workflow:

  1. During the creation of the package to be tested

  2. During the tests

  3. During the creation of the package to be deployed

Build

As soon as the testing package is created, the tests will start:

PHPCS build start

And that's it! You just configured your application to be tested with PHPCS!

Downloads

When the build is finished, you can download the PHPCS reports that continuousphp automatically generated:

  1. The full report

  2. The info report

  3. The gitblame report

Simply go to the build list and click the Download button to see which downloads are available for your builds.

Environment Variables

You can use Environment Variables to configure your testing environment. Simply go to the Test Settings (step 2 of the pipeline configuration), open the PHPCS configuration and add one or more Environment Variables:

PHPCS Env Vars

Encryption

Environment Variables can (optionally) be encrypted. Pay attention that, once a variable is encrypted, you can no longer obtain it's value. An encrypted Environment Variable can only be decrypted during a build by continuousphp's workers. Encrypted Environment Variables will be masked in the build output.