Upgrade Your PHP Version
So you want to upgrade PHP. Since around PHP 5.5, The core team has been releasing a new version of PHP on a yearly basis. That sounds pretty intense at first. Some people and organizations can feel overwhelmed by it. However, each version comes with 2 years of active support, plus a year of security updates. That’s 3 years of support for a single version version of PHP.
So why do they feel overwhelmed? I think they’re under the impression that they are required to upgrade every year. When you’re responsible for managing a business-critical application, your priority is to create business value — that means creating new features, and fixing bugs. You don’t want to have to worry about needing to upgrade PHP engine for your application. That’s understandable. So how can you feel better about the process of upgrading PHP?
Change Your Thinking
Don’t think of it as an obstacle. Instead it’s an opportunity to improve your application. When a new version of PHP is released, there is usually a performance improvement. Security improvements are also common in PHP versions. So you get these things for free, just by keeping your code up-to-date.
Test Coverage
Every application needs to have tests. You should already be using them to check your code changes didn’t break anything. Your application should have unit and integration tests. These tests will also ensure your environment is working correctly – like when you upgrade your PHP version. The better your tests, the more confidence you can have that your php upgrade is successful. So, if you’re still not sure about your application, improve your tests.
Strategy
Today is 2019 Nov 30, and PHP 7.2 entered the security only updates. PHP 7.4 (the latest version) was just published yesterday. If you’re application is currently on 7.2, you should begin working to upgrade php to 7.4 for all your applications. You don’t want to wait until your version goes end-of-life (EOL) before you start thinking about upgrading. When your PHP version enters security-only updates mode, begin updating to the latest version
. That’s a good long term business approach.
When your PHP version enters security-only updates mode, begin updating to the latest version
If you are more forward thinking, you should follow the core updates, as they are released. Before the official releases are published, test out your code on the release candidates. This will ensure your application works well when the official version is released. By keeping up, as the versions are released, it’s a smaller amount of work over time. You will be building the habit of maintaining quality code. Over time, the PHP version numbers will change. You should check the currently supported versions of PHP, to evaluate which version you want to choose .
You want to make it easy to upgrade PHP. Start by addressing the deprecated code and removed features. This prevents your applications from breaking. Then look for opportunities to update your code to use the newly added features.
Conclusion
You don’t need to worry when you upgrade PHP version. Don’t look at it as a one-time event. Think about the future as you write code, as you build your application. This will keep you future friendly, and prevent you from getting stuck in the past.