PHP 5.6 End of Life is coming at the end of this year, 2018.
PHP 5.6 has been the stable go-to version of PHP for PHP-based web applications for 4 years. Any PHP web applications written prior to the last 4 years will have been written for PHP 5.6. So, if you’re currently running PHP and the application is older than 4 years, there’s a good possibility it’s running in PHP 5.6. Let’s dive in…
What PHP 5.6 End of Life (EOL) Means
All good things come to an end.
PHP 5.6 End of Life (EOL) means that this PHP version will no longer receive any security updates or bug fixes. There has been fixes and updates throughout the life cycle of PHP, and for PHP 5.6 these will stop.
Your PHP application and website will continue to continue working.
But… if there are any security vulnerabilities discovered after the EOL they will not be fixed. This will leave your website, web application, e-commerce store or blog vulnerable to potentially getting hacked.
This means, if there are any bugs discovered in PHP (or one of its any libraries), it will won’t be fixed.
When is this happening?
End of Life for PHP 5.6 is December 31st, 2018.PHP 5.6 was originally released August 28th, 2014.
Active support for PHP 5.6 ended on Jan 19, 2017. While in Active Support reported bugs and security issues are fixed with regular releases. Since Active Support ended PHP 5.6 has been in Extended, or “Security Fix only”. During the extended Security fix support period only, critical security fixes have been released. PHP 5.6 has been in extended security fix period of almost 2 years.
Essentially, End of Life means the extended security fix period is now coming to an end on December 31, 2018. After the end of this year PHP 5.6 will no longer receive any updates, security fixes, or bug fixes.
It’s been a good run and time to upgrade from PHP 5.6.
Here are the PHP Supported Versions:
How many Websites are still running PHP 5.6?
PHP 5.6 is a very popular version and currently powers close to 79% of the web.
Off all the websites running PHP, here the break down of the different versions of PHP in the wild:
76% of PHP websites are still running PHP 5.6. If you add the PHP 7.0 (also EOL in December 2018), there’s still a lot of website running a soon to be End of Life version.
According to WordPress, PHP 5.6 and PHP 7.0 are still used on over 56% of WordPress installs. If you add the number of websites not using WordPress, that number will be higher.
Why the Adoption rate of new versions of PHP appears to be slow?
PHP 7 was released in December 2015, so why are so many websites still running the older PHP 5 and 7.0 versions?
Let’s look at why this may be. It will give us some insights as to why you may have not upgraded yet.
- The main reason is that business owners don’t understand the technology behind their website or applications. Much of this technical stuff has been left to the developer or website host.
- Budget is a factor is the slow adoption of newer versions of PHP. It takes programmers time to modify the code and test the application in new versions of PHP. You simply can’t just simply upgrade the server without testing or modifying the code. Programmer time to do this comes down to budget.
- Time for testing and upgrading. Developers have to test their code and applications in the latest version before they can roll out new code updates. Some functionality of the application may need to be rewritten and modified. The more complex the application and code the more time it takes to complete.
- Web Hosts don’t want to break compatibility. Web hosts are not responsible for maintaining the website and application code. So, although most web hosts will provide the option to upgrade the server, they are not pushing clients to do this, because if they push the PHP update on the server and it breaks the website, this will result in increased support calls and tickets for the web host. You’ll need to hire a programmer to update and test the code first before rolling out the web hosts latest PHP version.
What you should do and how to prepare
Let’s look at what we can do and how to prepare of the end of life of PHP 5.6.
The best option is to upgrade to the latest version. As of this writing, the latest version is 7.2. PHP 7.3 is right around the corner, with a planned release date in December.
With the new release in December 2018, you may be asking, “should I wait and just get the latest version?”
No. The difference is changes between minor versions like 7.2 to 7.3 are small and will take less effort, if any, to upgrade.
The upgrade from 5.6 to 7.x is a bigger deal, as there has been a lot of changes.
Plan for a server upgrade. Most software is compatible, but plan for a compatibility test.
You shouldn’t upgrade just the server without testing, and potential code changes.
Why you should upgrade to PHP 7.x
If PHP isn’t going to stop working, why upgrade at all?
Good Question. Let’s look at why you really should upgrade.
There won’t be any more security updates. So, if there is a security vulnerability found days, weeks, or months after the End of Life ofPHP 5.6, you won’t receive any security fixes. No matter what you do to the code of the website, if the security is in the programming language, you may not be able to work around it.
Occasionally bugs are discovered within the programing language. Although PHP 5.6 is very mature, some bugs may still be discovered. Granted, the will likely be obscure. If you make code changes to the application, a bug in PHP or one of its libraries may suface later down the line.
PHP 7 release saw a rewrite of the Zend Engine, adding massive speed enhancements to PHP. We’ve seen 3x and 4x performance improvements when upgrading from PHP 5.6 to PHP 7. PHP 7 is just more performant.
Going forward, if you have an application installed, the newer versions of software going forward will not be written for older versions of PHP. Existing applications will start dropping PHP 5.6 compatibility in the future. Developers don’t support versions of PHP that are at the End of Life.
Here’s more information on why you should upgrade PHP. Let’s get into how this is done…
How to tell what version of PHP a site is running
Let’s talk go over how to proceed… The first step is to determine which version of PHP you are running now. This will determine what you need to do.
There are a number of ways to test your version of PHP, depending on your access to the server and technical expertise.
PROFESSIONAL PHP HELP
Do you need professional help with checking, testing or upgrading PHP?
PHP Version Review
Check PHP version with the Command line/SSH
If you have command line access and know how to use the command line, this is the fastest way to tell if which version you’re running. Simply login to the command line.
In Microsoft Windows, you’ll want to use a terminal client, like PuTTY.
Once you are logged into the terminal with the username and password enter the following command:
# php -v
You’ll get a response like this:
PHP 7.1.16 (cli) (built: Mar 31 2018 02:59:59) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
This tells you’re running PHP 7.1.16
How to check PHP version in cPanel
If you have access to cPanel login and under general information, click on Server Information. Under the Item column you’ll find the PHP Version.
Some customized cPanel installs you may find this differently. There may be a PHP Selector in the Software section. The first PHP version in the selector is the one installed.
How to check PHP version in Plesk
If you have access to a Plesk control panel, login and navigate to the domain. Under the PHP Settings, the Version number will be displayed.
How to check PHP version in WordPress
If you are unable to login to a control panel or don’t have SSH access, but have WordPress installed, you can determine the PHP version from directly inside WordPress.
You’ll need to have Administrator access to do this, as you’ll need to install a small plugin.
Once logged in, click on plugins, then Add New Plugin. Search for the plugin, “Display PHP Version” and install it, and click Activate.
Once activated, click on the Dashboard link in the left menu and look under the “Ata Glance” section of the dashboard. The complete PHP version will be displayed.
How to check PHP version using Web/FTP
If you have FTP and Web access to the server, another option is to use a PHP file and function to determine your PHP version. You will need FTP/SFTP credentials to be able to log in through FTP and upload a file. ThoseFTP credentials include hostname, username, and password.
First, you’ll need to create a blank text file named info.php. in this text file paste the following code:
Next, you can use an FTP client (like Filezilla) to upload the file to the website and run the file in a browser. Go to your domain/info.php and view the file. Once you view the file in the browser you’ll see the version of PHP at the top.
Make sure once you complete checking the version this way, you delete the info.php file. Leaving this file on the server displays a lot of internal information about the web server and is considered a security risk.
Call Host or Support
If you exhausted all these options and are still unable to determine the version of PHP running on the server, you may need to contact your hosting company and ask them to let you know which version of PHP is running on the server, and which versions are available.
Some PHP Changes
Once you determine the version of PHP on the server. Don’t simply just upgrade PHP on the server. There may be some incompatibilities that may cause issues with the code. The number and complexity of code changes potentially required for your site is dependant on the existing code, the version of PHP you are currently running and the version you plan to upgrade to.
PHP 5.6 to 7.0 changes
Here are some of the changes in the PHP that cause incompatibilities in the code when upgrading from PHP 5.6 to PHP 7.0:
- set_exception_handler() is no longer guaranteed to receive Exception objects
- Code that implements an exception handler registered with set_exception_handler() using a type declaration of Exception will cause a fatal error when an Error object is thrown.
- Parse errors throw ParseError
- Parser errors now throw a ParseError object. Error handling for eval() should now include a catch block that can handle this error.
- E_STRICT notices severity changes
- All of the E_STRICT notices have been reclassified to other levels.
- Changes to variable handling
- Code that used the old right-to-left evaluation order must be rewritten to explicitly use that evaluation order with curly braces.
- Changes to list() handling
- list() will now assign values to variables in the order they are defined, rather than reverse order.
- Empty list assignments no longer allowed
- List() can not unpack strings
- Array ordering when elements are automatically created during by reference assignments has changed.
- Parentheses around function arguments no longer affect behavior
- Foreach loop changes
- No longer changes the internal array pointer Foreach no operates on a copy of the array
- Changes to division by zero error reporting
- ASP Tags removed
- New objects can’t be assigned by reference
- Switch statements can’t have more than one default block
- $HTTP_RAW_POST _DATA variable has been removed
- JSON extension replaced with JSOND
- Mhash extension removed
- This is used for password hashing.
- Mysql and mysql extension removed
- Mysql function was deprecated in PHP 5.5 removed in 7.0. Using the older mysql_ functions will just break all the database connections. Database connections need to rewritten.
- Ereg extension removed
- Replace any ereg functions with compatible functions.
PHP 7.0 to 7.x changes
If you are upgrading from 7.0 to 7.1, these are some changes to PHP that may cause issues:
- Invalid class, interface and trait names
- If you have function or variable names that are now reserved, they will throw error in the new version of PHP.
- The empty index operator is not supported for strings anymore
- Applying an empty index to a string throws a fatal error, now.
- Array ordering when elements are automatically created has changed.
- Fatal errors to Error exceptions.
- In the Date, DBA, DOM, IMAP, LDAP, mbstring, mcrypt and mysqli extensions Fatal errors now result in an Error exception thrown. So, if you’re checking for errors during code execution, it’s been improved, but may not work as expected with older versions.
- mb_ereg() and mb_eregi()
- third parameter changed being set to an empty array if nothing was matched.
- Dropped support for sslv2 stream
- sslv2 was dropped from OpenSSL
- Additionally, there are some function changes to the following functions
- Getopt(), Getenv(), Get_headers(), Output_reset_rewrite_vars(), Parse_url(), Unpack(), PDO::lastinsertid(), Pg_* postreSQL functions,
- now returns false and no longer initializes a session when it failed to start a session
Some of these changes may be obscure and may not affect your application or code. While some are very major. It depends on what functions the code uses and how it uses them.
It’s best to test the application and make sure these changes to PHP don’t break your application before upgrading to the latest version of PHP.
More information about PHP changes is available on the PHP website.
How to upgrade to PHP 7.x
1. Determine the current version
First, determine the current version of PHP on the server from the step above.
2. Check compatibility
So, you’ve determined you need to upgrade. Out of all the changes to PHP, you need to determine if these changes to the PHP core and PHP libraries will break your website.
Let’s look at how to go about determining this…
If you are running WordPress, it’s simple. WordPress itself isn’t the issue (if you have the latest version). Issues with WordPress comes into play with themes, plugins and custom code. You’ll want to make sure everything installed in WordPress is compatible with the latest release of PHP.
There’s a great plugin that will help you determine this. Download the “PHP Compatibility Checker”
Looks like this plugin only works correctly in PHP 5.6. If you are already running PHP 7.x it may not function correctly. It will scan the PHP code plugins and themes to determine if you’ll have any issues upgrading.
This will not fix your site. It will just determine if you’ll have issues and identify which plugins you may need to replace, if you can’t upgrade.
Command Line Tools
If you have a PHP application (which is not WordPress), here are a few testing applications, so you don’t have to go through code line-by-line to determine if there are issues.
These command line tools will scan your code for you, and help identify incompatibilities. But obviously, fixing these issues will require some PHP programming knowledge. You’ll be able to at least tell how big a deal it is.
PHAN is a static analyzer tool. It requires PHP 7.x to run, so you’ll want to install the software on a local server running PHP 7.x latest version. Then download the code base you want to test and scan the code. The recommended way to install PHAN is with composer.
PHPStan (PHP Static Analysis Tool) works in the same way. Download the code to be scanned onto a development server and install PHPStan with composer. PHPStan will find the potential errors that need to be fixed.
If you don’t want to go the command line route, PHP Storm 10 will help get your code PHP ready. PHP Storm is a PHP IDE (IntegratedDevelopment Environment) for developers to help programmer code faster. PHPStorm is a paid editor after the 30-day trial, but if you need it to speed up the upgrade it’s a great option for some.
3. Test Server Set up
It’s highly recommended to set up a separate local development or another server that has the version of PHP you plan to use and test the code. Don’t upgrade the code directly on the production server, unless you are very comfortable there will not be an issue.
If there’s a chance it won’t run, it could bring the website down.
4. Resolving issues
Let’s talk about how we go about resolving issues once we have a test server setup. Depending on the software you’re running, let’s cover the major issues to keep in mind.
If you are running WordPress, these are the step you could take.
- Upgrade to the latest version of WordPress
- Run the PHP Compatibility Plugin
- Upgrade, Remove or replace plugins that are not compatible
- Upgrade PHP on the server or migrate hosting
Depending on which version of Magento you’re running the commendations are slightly different.
Today, the latest stable version of Magento is 2.2. If you’re running version 2.1, you’ll want to upgrade Magento to version 2.2. Magento 2.3 is in beta, so for a production environment, it’s not recommended, yet
Magento 2.2 (stable) is currently not compatible with PHP 7.2, so you’ll want to upgrade PHP to the latest 7.1.x branch
According to Joomla’s website, Joomla 3.x is compatible PHP 7.0+. But Joomla requires the mcrypt library so it will only be compatible with PHP 7.1 and not 7.2+. Installing the mcrypt library is not recommended, and it was removed for a reason, so stick with PHP 7.1 for now.
If you’re running Drupal 7 upgrade to the latest version 0f drupal and upgrade to the latest PHP 7.2 .
If you’re running Drupal 8, upgrade to PHP 7.2+ and Drupal 8.5.0
Any version of Drupal below 7 will require a Drupal upgrade.
Drupal has a compatibility check for modules. Use this to make sure all the modules are compatible with the planned version.
SilverStripe version 3 users should upgrade to at least v3.6 and PHP 7.1, as PHP 7.2 isn’t supported.
Version 4 installs should upgrade to PHP 7.2
Modx Revolution 2.x users can upgrade to PHP 7.2
Concrete version 7 users need to upgrade to PHP 7.1, PHP 7.2 is not supported. If you’re running Version 8 Upgrade to PHP 7.1. The Concrete5 website claim 7.2 is supported but requires mcrypt library. Installing mcrypt in PHP 7.2 is not recommend. It was removed from PHP core for a reason, so, stay with PHP 7.1
Custom PHP Applications
You may need to call a programmer for these steps
- Setup a development server with the latest version of PHP.
- Run one of the command line PHP static analyzers PHAN, PHPStan
- Use PHP Storm or other IDE to examine the code
- Identify and resolve the issues.
Test, Test, Test
Make sure to test the code on the new server. I can’t emphasize testing enough. It’s better to spend some extra time testing than upload a broken site.
Deploy the Updated PHP Code
Finally, upload the updated code to the new server with the latest version of PHP installed
PHP 5 will reach it’s the end of life on December 31st, 2018. PHP 7.0 already reached the end of life on December 1st, 2018.
Again, your website will continue to function, but you should plan to upgrade as soon as possible. This guide outlines the steps to take for y our website.
ON YOUR WEBSITE?
We can Help with the Upgrade