Code Each Day. Day 1. Scrutinizer, Travis and Symfony

Posted September 22, 2014

Day 1 was a success. I have used Scrutinizer and Travis before in open source projects but never spent the time to really read the documentation about how its used and what it can offer. Following in the rules I set out for writing “Minimum valuable code” each night I focused on getting CI set up for my project and understanding what is possible from the solutions I have used before.

So I decided to use;

The reason I am using two services is because, Scrutinizer free account does not run tests. I plan on having a full suite of Features and Specs so automating these on build is a must have. Travis on the overhand does not show metrics on code quality in the same way that Scrutinizer can.

Lets start with Travis. Both tools are very simple to set up and configure. All you need to do is log in with Github and select the repository you want to use. Once you select the repository both services set up web hooks to monitor for new commits and pull requests.

For travis I stuck with a simple configuration file ( .travis.yml )

language: php

php: [5.5]

  - composer selfupdate
  - export COMPOSER_ROOT_VERSION=2.0.0-RC3
  - composer install --prefer-source

  - bin/phpspec run
  - bin/behat

What is interesting here is that I can set what instances of PHP I want to run run Travis against. Just by adding to the array I can add as many different PHP versions as I want and Travis will create a new container for each to test against. Before script sets up the container by running composer to pull in all dependencies and script will run all the tests I have set.

Scrutinizer configuration is just a case of adding ( .scrutinizer.yml ) in the root of the project again. I went with another simple configuration that enables all the functionality I need to get started with the project:

        code_rating: true
        duplication: true

    external_code_coverage: false
    php_code_coverage:      false
        config: { standard: 'PSR1' }
    php_changetracking: true
    php_cpd: true
        config: { level: 'psr1' }
    php_mess_detector: true
    php_pdepend: true
    php_analyzer: true
    sensiolabs_security_checker: true

    paths: [ 'src/*' ]

The filter section is important as this tells scrutinizer to only look in src for files to analyse. The rest of the configuration relates to what QA tools to run over my source code, PHP_CS_Fixer is a good addition to have enabled as any code style violations that are detected Scrutinizer will create a pull request resolving for you..

So day 1 complete, I have a project set up on Github with CI configured via Travis and Scrutinizer

Day 2 will focus on setting up some entities within a core domain and depending on time looking at setting up controllers as services and configuring or planning the DI layer.

You may also find these related posts interesting: Developer Book Club All hail Xdebug and lets let var dump die A new look and a cleanup of content plus good bye github pages. Docker and Docker Sync