December 7, 2020

WordPress, Drupal, Laravel, Symfony… how do you test a PHP version upgrade?

James Sansbury

Heads up, PHP friends, PHP 8.0 is here, and you’re going to want it. The performance benefits of the new JIT (just-in-time) compiler are reason enough, especially if your application has CPU-intensive processes. Here’s a full list of the changes in PHP 8.0. And while you’re at it, check out our post on how to turn on JIT compiling in PHP 8.0.

For PHP-based CMSes and web frameworks, a major version change of PHP can be a bit daunting. You may have a dev or staging server that gives you an option to change the PHP version independently of production. Unfortunately, that’s not a great place to tinker with things as you may block other workstreams.

A picture of Kramer with smoke rising from his head.
Smoke testing a new PHP version directly on Stage.

Don’t use staging to test a software version upgrade

Instead of using a staging environment to test a software version upgrade, take advantage of Docker-based tools. This allows you to test different versions of PHP side by side without blowing up the staging environment if (when?) you run into a snag.

For example, if you’re using Tugboat, you might have your PHP service listed like so:

   image: tugboatqa/php:7.4-apache

To test an upgrade to PHP 8, you can create a new branch and associated pull request, and make this one-line change.

   image: tugboatqa/php:8.0-apache

Since Tugboat is Docker-based and free for everyone, this is an easy way to get started testing version changes like this without interrupting other workstreams on your project.

Use Tugboat’s built-in shell to debug

Once you’ve made a PHP version change, you’re likely going to run into issues. Did you know that Tugboat has a built-in terminal that you can access right from your browser?

Tugboat Dashboard showing a debugging session.

Using that Terminal, you can try out a few commands to see what might be causing the failure. Once you get those commands figured out, commit your changes to your Tugboat config, and push up those changes to trigger another build.

Want to tinker with JIT compiling?

If you’re curious about how JIT compiling will perform, go ahead and enable it on Tugboat to try it out. You can read the details of how to turn on JIT compiling in PHP 8.0, but a quick way to tinker with it is to add the following to your init commands of your PHP service in your Tugboat config.

       - docker-php-ext-enable opcache
       - printf "opcache.enable_cli=1\nopcache.jit_buffer_size=50M\nopcache.jit=tracing\n" > $PHP_INI_DIR/conf.d/tugboat-jit.ini

Once that change is made, you’ll need to build a preview with no Base Preview.

Infrastructure as code? Infrastructure with code.

Since Tugboat’s configuration lives with the source code for your application, you can change the PHP version and fix the bugs associated with it, all in the same branch or PR. This is the huge benefit of Tugboat’s infrastructure-as-code approach to configuration. Your Tugboat configuration is using the same versioning system as your source code itself.

So, don’t wait until you’re forced to upgrade PHP before testing it out. Sign up for Tugboat today and see how your website or web application performs on PHP 8.0.

Need More Info on Tugboat?

Tell us about your project, schedule a demo, or consult with a Tugboat Technical Account Executive.

Your request has been sent.
Oops! Something went wrong while submitting the form.