Continuous Integration With the Phalcon Framework

The Phalcon framework has rapidly evolved over the past few years. Once a small project, the framework now boasts over 6000 Github stars and is one of the fastest growing PHP communities of 2015. At the start of 2014, Phalcon’s popularity reached 16%, a comfortable second to Laravel. However, since then the popularity has continued to grow and I would not be shocked if Phalcon becomes the standard in PHP frameworks for new development in 2016.

One of the key components in an agile application life-cycle is a streamlined continuous integration and testing process. These processes are important because they provide validation and verification of an application’s components. In enterprise deployments, testing is a crucial. The usual vehicles for this sort of integration typically included homebrew Jenkins or Teamcity installations. These in-house solutions have been phased out as hosted CI services including Travis CI, Circle CI, Codeship, and Shippable have become the defacto standard while also reducing complexity and cost.

Installing Phalcon in a hosted CI environment is slightly more challenging because Phalcon does not have a stable package release (although these are being worked on actively). Coupled with various nuisances of container requirements, sudo restrictions, or other AUFS issues, it takes a little bit of tweaking to get it just right. In order to address this, we’ve open sourced our Phalcon CI Installer in Github, which provides drop in composer integration for easily adding Phalcon as a PHP extension.

Installation is simple:

  1. Add the techpivot/phalcon-ci-installer repository into the require-dev section of your composer.json as follows:
      "require-dev": {
          "techpivot/phalcon-ci-installer": "~1.0"
      }
  2. Update your CI script to execute the vendor/bin/install-phalcon.sh installer in the relevant section. See the examples in the Readme for explicit snippets for various CI providers.

With the Phalcon installed, the power of your unit tests via phpunit are endless. Additionally, using any headless webkit testing or selenium testing is now possible as the Phalcon application can mock production inside the CI environment.

Happy testing!

Feel free to drop me a line if you have any questions or issues.