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.
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:
To test an upgrade to PHP 8, you can create a new branch and associated pull request, and make this one-line change.
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.
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?
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.
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.
Once that change is made, you’ll need to build a preview with no Base Preview.
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.
Tell us about your project, schedule a demo, or consult with a Tugboat Technical Account Executive.