Continuous integration (CI) lets a development team operate more smoothly, keeping everyone’s changes together as they make them. It avoids the need to bring together branches that have gotten badly out of sync with each other. This means less wasted time and frustration. Codeship is one of the best CI tools for PHP developers.
Codeship for Continuous Integration
Codeship‘s cloud-based service eliminates the need for a development team to set up its own integration and testing platform. It works with the team’s code repository to trigger an integration and test run each time the developers commit new code. Even if the change is just to a small utility function, the commit will make sure everything is still running. How many times have developers gnashed their teeth over unexpected bugs while declaring, “But I only changed one line”? With CI, they’ll discover the problem immediately and be able to fix it before it creates more confusion.
Sometimes everything works fine on a developer’s local version but fails integration testing because some necessary piece wasn’t committed to the repository. Developers may be using different versions of a library, with unexpected results when everything comes together. CI helps to catch those mistakes quickly.
If an integration fails, team members can receive email notifications. They can also get notified when the problem is fixed and the code passes all tests.
Developers can use Bitbucket, GitHub, and other repositories. If Codeship doesn’t already have support for their repository, they can set up a script to trigger integrations.
Codeship and PHP
PHP support is a strong feature of Codeship. It supports PHP versions from 5.3.29 through 7.1.0. It supports pear and composer for setting dependencies, xdebug for debugging, and PHPUnit for tests.
All the pieces for automated testing of Web applications are available. Database support includes MySQL, PostgreSQL, MongoDB, and many others. Developers can set up their code with the database of their choice and run Web applications in a Firefox or Chrome environment. For unit testing, they can combine PHPUnit with Selenium. This approach also works for integrating and testing support code, such as WordPress plugins and themes.
Continuous Integration goes with Continuous Delivery (CD), which extends the idea to frequent deployments in a working environment. With CD, alpha and beta testers stay up to date with the latest code. Developers can deploy from Codeship to Laravel Forge or Heroku, or to other platforms with custom scripts. Familiar Linux file transfer commands such as sftp, scp, and rsync are available for deploying to a host. PHP developers may prefer the language-specific Rocketeer or Deployer. A Codeship deployment pipeline allows automatic deployment to one or more targets if the code passes all the tests.
Starting Out on Codeship
Codeship offers Basic and Pro versions. The emphasis in Basic is on ease of use, and in Pro on powerful features and containerization. Basic includes a free version with limited capabilities, a Starter version recommended for individual developers, and an Essential version for small teams. Codeship Pro adds full customization and native Docker support. Pro options range from Small through Massive.
Getting Codeship working is very quick, but setting up the integration environment can take significant effort. It’s necessary to set up a repository connection, choose the PHP version, set up environment variables, and add any needed supporting software. Once everything is set up, developers can simply commit and get information back quickly. The bigger the project is, the more setup work is required, but the return in saved time will be even greater.
With Codeship, PHP development teams can adopt CI practices with a minimum of effort, helping them to keep their schedules on track.