Update March 2020 - I’ve given written a newer more updated version of this article, check it out over here.
Gitlab provides some good documentation on getting build runners for your projects set up which can be found here. However I haven’t found a good article on setting up Gitlab CI for PHP applications yet.
This article is not going to discuss setting up shared runners on Gitlab since I felt the documentation provided by them in the link above was easy enough to follow, what this I am going to focus on is the
.gitlab-ci.yml configuration that I’m currently using in my projects to do the following:
- Run PHP CS against our code base to ensure that it conforms to PSR-2
- Run PHPUnit against our code base to ensure that our unit tests pass against different versions of PHP (5.6, 7.0, 7.1)