Continuous Integration with PHP-CI

Share this article

Creating an application is one thing. Keeping it to a certain quality level is another thing entirely. These days, you can find many tools which can help you to keep the quality of your application in shape. Running these tools one by one can be very time consuming. For that, you can install so called continuous integration (CI) services. PHPCI is one of those and in this article, we will dive into it.

Continuous integration service

A continuous integration service is an application which runs certain quality check tools against your code. For example, a CI could pull in your git repository. When done, it runs unit tests, checks your code for validations and generates reports based on it. In general, a CI runs on certain time intervals or on every push. The most seen situation is right after creating a merge request. By checking the merge request, the code is checked before being merged, making sure you are not accepting code which could break functionality. So integrating CI within your development procedure can make sure bad code is kept out of your main repository and you can validate automatically if everything meets your requirements before accepting changes.


Installation can be done in two different ways. Either you download the latest release or you follow the installation guide. I decided to go with the installation guide and install it through Composer. After running composer update you can run the install script. You will be questioned for database credentials and your email address. When done, a user is created with the given email address.

You also need to set a cronjob so builds are run automatically.


Depending on what you want to do, you have to install some tools. After logging in, you can go to admin manage plugins and install any necessary plugins. By installing a plugin, you are updating the composer.json file with new requirements. So right after you installed the plugins you need to run composer update to actually install these plugins.


Add a project

By clicking the add project button in the header, you can create a new project. You have to fill in a simple form, which indicates were the code is located. You can choose between different kinds of services like Github and Bitbucket, but also for your own remote or local URLs. If you don’t have a phpci.yml configuration file within your repository, you need to provide the build configuration. Within his configuration, you define how the project needs to be set up, which tools you want to run and how to finalize the build.

Each build process consists of 5 phases.

  1. Setup. The phase were everything is initialized
  2. Test. The phase were all tests are executed
  3. Complete. Success or failure, this part will always run
  4. Success. Will only be run in case of success
  5. Failure. Will only be run in case of failure

I will be using this project as our project. We want to ignore default directories like app and vendor. Installation will be done through Composer. The project should be PSR2 compliant, has unit tests and contains decent docblocks. We also want to check if the overall quality is fine by running PHPMD, PHPCPD and PHPLoc.

PHPCI is capable of handling a test database. However, the project we are using in our example does not have any functional tests, so we will leave out the MySQL connection.

Let’s take a look at what the configuration would look like.

        - "vendor"
        - "bin"
        - "app"

        action: "install"

            - "app/phpunit.xml.dist"
        coverage: "coverage"
        args: "--stderr"
        allow_failures: true
        standard: "PSR2"
        allow_failures: true
        allowed_warnings: 10
        skip_classes: true
        directory: "src"

After creating the project, you have to make sure that PHPCI is capable of retrieving the project from Github. In this case, I added the SSH key which PHPCI supplied me to my Github account. When done, you can click the build button to start building the project.

Build results

When the build is completed, the project will get a color matching the status on the overview page. You get a clear view of the previous build, the latest commit and the current branch. By clicking on the ID of a build, you can see the in depth results for the build.


Time to take a closer look on the results of a single build. Near the top of the page, you should be able to see two small graphs. One will indicate the lines of code while the other one will display the quality trend. The quality trend graph contains an overview of all the tools like PHPMD and PHPCPD.

Unfortunately, I was unable to get PHPLoc working correctly

Beneath the graphs, we can see in depth results per tool. For example we can have a look at the unit tests. In this case, I was aware of the fact that they should succeed. Within PHPCI, this was also the case. PHPCI indicates this, by leaving the table empty.


In case of a failure, PHPCI will clearly indicate what is wrong by retrieving feedback from the tool. In my case, PHPMD had some lines which they think could be improved. PHPCI shows me which file and what the message is. Next to that, I am able to click the file to go straight to my Github repository.


All the tools I used gave the same way feedback to me. Tables which are empty where successful, tables which were filled had some improvements.


Of course, PHPCI can do more than what was described above. If you are interested in all its features, have a look at their documentation. Basically, it can use any PHP QA tool you know.

So, what’s my final verdict? I have been using lots of tools in the past. A year ago, I was convinced that there was no single tool that could beat Jenkins. Till today, I still believe Jenkins is one of the best CI tools out there. Jenkins is capable of running all kinds of projects, not only PHP based ones. For me, that is a huge advantage when you are dealing with JS, iOS and Java applications. Jenkins is full featured, contains a lot of plugins and is capable of creating nice graphs about the quality of your project. It only lacks a nice and structured design and easy configuration.

I also love Travis in combination with Scrutinizer and SensioLabs Insight. Together they can give me a lot of feedback on my code and run all kinds of checks. However, if you are not working with open source projects, you have to pay for all three services to keep them running.

So, is PHPCI a nice addition in this line of tools? Yes, I believe so. They are really trying to target the PHP community and are offering one, single place, to run all kinds of checks. Next to that, it can already produce some graphs to give a quick overview of the quality of your project.

Don’t forget, PHPCI is not even a year old yet and that’s something you will notice. Installing a plugin requires you to run composer update, which means you still have to log in to your server. Also, the design sometimes is really off, especially when you are installing a package and you need to pick a version.


I would like to see some more helpful information on certain topics. It’s nice to know you have to fill in a configuration file, but if it could show you the possibilities or at least add a link to the documentation, that would help a lot. You might even wonder why the documentation is not integrated within the tool itself.

The most frustrating part for me was the fact that I received messages like Plugin Status: Success and Plugin Status: Failed in my console and the build was giving me an empty table.


I believed it meant that it somehow failed to run a tool like PHPUnit. Yet it tells you if PHPUnit actually succeeded or failed. A success also leads to an empty table, so you basically have no feedback in PHPCI itself. Would be nice if it just said something like “everything is ok…. moving on!” or at least gave me the results of PHPUnit.

Finally, it’s good to see the developers are also extending it with custom tools. For example, they created a docblock plugin. For now, I believe it only checks if a docblock is present or not. Would be nice if they could check all docblocks in the future to match the upcoming PSR-5 standard.

If you don’t want to set up Jenkins or you have a private project and you are only developing PHP projects, PHPCI could be the tool you are looking for. Personally I would wait a bit longer until they improve the design of the application before using it on a real project. It sometimes feels a bit clunky because the design is unclear or there is no correct description.

Are you currently using a CI tool? Do you think PHPCI could replace your current CI? I would love to hear from you in the comments below.

Frequently Asked Questions (FAQs) about Continuous Integration in PHP and CodeIgniter

What is the significance of Continuous Integration in PHP development?

Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early. In PHP development, CI helps in maintaining high-quality code, reducing bugs, and speeding up the development process. It ensures that the code is always in a deployable state, making it easier for teams to work together and release updates faster.

How does CodeIgniter fit into the Continuous Integration process?

CodeIgniter is a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web applications. It fits into the CI process by providing a robust and easy-to-use platform for developing PHP applications. CodeIgniter’s simplicity and clear documentation make it easy to integrate into a CI pipeline, allowing for automated testing and deployment.

What are the benefits of using CodeIgniter in a CI environment?

CodeIgniter offers several benefits when used in a CI environment. It’s lightweight and straightforward, making it easy to integrate into a CI pipeline. It also has excellent documentation and a large community of developers, providing plenty of resources for troubleshooting and learning. Additionally, CodeIgniter’s MVC architecture makes it easy to write testable code, a crucial aspect of CI.

How does Continuous Integration improve the quality of PHP code?

CI improves the quality of PHP code by enforcing regular code integration and automated testing. This means that any errors or inconsistencies in the code are detected and fixed early in the development process. CI also encourages developers to write testable code, which leads to more robust and reliable applications.

What tools are commonly used for Continuous Integration in PHP?

There are several tools available for CI in PHP. Jenkins is a popular open-source tool that provides continuous integration services for software development. Travis CI and CircleCI are also widely used, offering cloud-based CI services. PHP also has specific tools like PHPUnit for unit testing and PHPCS for checking code standards.

How can I set up a Continuous Integration pipeline for my PHP project?

Setting up a CI pipeline for a PHP project involves several steps. First, you need to choose a CI tool that suits your project’s needs. Then, you need to configure the tool to build and test your code whenever changes are made. This usually involves writing scripts or configuration files that define how your code should be built and tested.

What are the challenges of implementing Continuous Integration in PHP?

Implementing CI in PHP can present several challenges. One of the main challenges is setting up the CI environment, which can be complex and time-consuming. Another challenge is writing testable PHP code, as PHP is a dynamic language and some of its features can make testing difficult. However, these challenges can be overcome with careful planning and the use of appropriate tools and practices.

How does Continuous Integration help in Agile development?

CI is a key practice in Agile development. It supports Agile principles like frequent integration, feedback, and adaptability. By integrating and testing code frequently, CI provides regular feedback on the state of the project, allowing teams to adapt and improve their code continuously. This leads to higher quality software and faster development cycles.

Can I use CodeIgniter with other Continuous Integration tools?

Yes, CodeIgniter can be used with a variety of CI tools. Its simplicity and flexibility make it compatible with most CI tools, including Jenkins, Travis CI, and CircleCI. You can configure these tools to build and test your CodeIgniter applications as part of your CI pipeline.

How does Continuous Integration contribute to DevOps?

CI is a fundamental practice in DevOps. It bridges the gap between development and operations by ensuring that code is always in a deployable state. This enables faster and more reliable deployments, leading to more efficient operations. CI also supports DevOps principles like automation, collaboration, and continuous improvement.

Peter NijssenPeter Nijssen
View Author

Peter is a software architect from the Netherlands. He freelanced for more then 6 years as a web developer, and meanwhile, he graduated as software engineer with honors. He decided to join CMNTY Corporation which specializes in creating community software and is now responsible for the ongoing development of multiple web applications as well as mobile applications. Peter believes a real developer is able to combine multiple techniques together to make sure the user receives the ultimate experience and enjoys using the application. In his free time, he loves to play board games with anyone who is interested. He especially has a passion for cooperative board games.

cicontinuous integrationjenkinsOOPHPPHPphp-citravistravis-ci
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week