Teamcity logo

The TeamCity Blog

The Hassle-Free CI and CD Server

Features How-To's Tips & Tricks

First-class PHP Continuous Integration using TeamCity

A while ago we blogged about using TeamCity to do Continuous Integration for PHP. TeamCity developers never seem to sleep: with TeamCity 8 a new feature called meta-runners was introduced. Meta runners allow us to reuse build steps by representing them as a native TeamCity runner. In other words, they allow us to make several build steps easier. Which is exactly what we decided to do: create some meta runners based on our previous blog post and make it really easy to run several PHP-related build steps.


The Meta-runner Power Pack for TeamCity 8 contains a set of PHP-related meta runners:

  • Run arbitrary PHP code using the PHP runner
  • Install a specific Composer dependency using the Install Composer package runner
  • Install/update packages from composer.json using the Run Composer runner
  • Run Phing build script using the Phing runner
  • Run PHPUnit tests (with code coverage reporting) using the PHPUnit runner

There is only one requirement: a PHP runtime should be installed on our build agent. The Phing, PHPUnit and Composer meta runners will automatically download the latest versions of the executables during the build! Full documentation for these PHP meta runners is available on GitHub.

Installing meta runners

After downloading the PHP meta-runners from GitHub, all files named MRPP_PHP_<name>.xml should be copied into the <TeamCity Data Directory>/projects/<Project ID>/pluginData/metaRunners/ directory on our TeamCity server.

Once this is done, the TeamCity server will list these new meta-runners under the administration page for the project in which the meta runners have been installed:


Using the PHPUnit runner

Since a big part of Continuous Integration is making sure the quality of our software is high, running unit tests is typically part of a build configuration. In the PHP world we typically use PHPUnit for this.

The PHPUnit runner allows running PHPUnit tests during the build and will optionally publish code coverage results to TeamCity. A build step using this runner will use a PHPUnit executable available on the build agent if specified, or automatically download the latest phpunit.phar from the website during the build.

To run unit tests, all we have to do is specify the path to our unit tests (but don’t worry, we can also tweak PHPUnit parameters):


This will run and report back unit test results to the TeamCity server.


And if we enable the Collect code coverage option, we get code coverage reports integrated with TeamCity as well:


Bugfixes and improvements for these meta runners (or your own, PHPLint and phpDocumentor runners would be nice!) are welcome through our GitHub repository.

Haven’t tried TeamCity? Give it a shot! It’s 100% free for up to 20 build configurations.

Let us know your thoughts through the comments below!

Happy building!
– The TeamCity Team

Comments below can no longer be edited.

7 Responses to First-class PHP Continuous Integration using TeamCity

  1. Deploying Committed Changes to a Remote Server | JetBrains PhpStorm Blog says:

    October 8, 2013

    […] flow, preferably automated. This can be done using a Continuous Integration (CI) server, TeamCity for example, which fetches the latest commit, runs PHPUnit and deploys it to the target […]

  2. Juan says:

    January 20, 2014

    Thanks a lot for these new PHP friendly features. Ive used TeamCity a lot when working with Java based projects, and im really happy to see that you are working to leverage PHP CI capabilities on it. Congratz!

  3. Juan says:

    January 27, 2014

    Just a small fix: The URI where xmls of meta runners should be copied is wrong. The correct one is /config/projects//pluginData/metaRunners/

  4. sergey says:

    February 5, 2014

    PHPUnit fails with “tccoverage does not exist”
    How can i fix it?

  5. TeamCity + Codeception + Laravel = Automated build testing | Joe Ferguson says:

    July 29, 2014

    […] that was made by JetBrains AND free? I was sold. I followed all the documentation and grabbed the PHP Meta Runners and set up my project and everything seemed to be glorious. I set up VCS triggers so that when we […]

Discover more