My PHP-based build and test systems on CircleCI


I’ve come here from having tried CodeFresh, and I much prefer CircleCI. I thought I’d do a quick write-up of what I’m doing, to help anyone else who’s getting started.

My project is in the deployment space and is built up of 14 utility and micro-service repositories, broadly all PHP and client-side JavaScript. Of these, nine of them have a Docker build phase and/or unit tests and/or functional tests using PHPUnit. Each of these have a CircleCI configuration, which does a Docker build and runs tests as appropriate. Seven containers are used at runtime, and they are wired together using HTTP or WebSocket APIs.

Where I do a Docker build, I sign into the Docker Registry at CodeFresh and push the resulting image. I have an integration test container, which then logs into the registry, pulls all the images, starts them up with Docker Compose, then runs browser-based tests using PhantomJS (which handles WebSockets with aplomb).

As standard with PHP projects, I use Composer and Git to pull from private repos - one of my repos is a Composer dependency, and I use a per-repo private key, committed into each repo, to permit Composer to build. (The dependency repo is low-value, so there is no disaster in the unlikely event the private key is exposed, but that would require someone to break into BitBucket, so…).

Most of my containers are based on Alpine, but some stuff (e.g. Phantom) seems to be tricky on BusyBox, so there I just use Ubuntu. Most of my container images average at a 70M size, one reaches 170M, but the Ubuntu one is 450M! It does not matter though, since the CircleCI layer caching seems to be working its magic (either that or it is just very fast at building). Thus, most of my build processes are in the order of 2-3 mins (ongoing development will probably increase that though, especially in the browser tests).

I use build badges in a simple HTML dashboard, with an auto-refresh every few minutes, for when I don’t want to load up the CircleCI JS frontend.

I have added a scheduled trigger of the integration tests container, using the Workflows feature; this runs twice a day. This means I spot if any pushed repos have caused a breakage, even when I have not made changes to the integration project.

In time I expect I will add code cleanliness tools (e.g. PHPMD, PHPMetrics and a todo collator) as part of the build process. These artefacts will be pushed to a dashboard server.

If anyone is getting started with PHP and would like some broad advice, ping me on this thread, and I will see if I can advise. :smiley_cat:


Hey. I’m facing this issue. Do you know anything about it?


I’m sorry to hear that, you have my sympathies. Which issue in particular, out of interest?

Yes, a fair bit. Would you narrow the question down? :smile: