If you have to come this article now with an intention to migrate your website from PHP 5.6 to PHP 7, first please be aware. Your time is already over. This is too late. Somehow you should get this done now. Do not postpone this work beyond this moment.
This is an overwhelming task. We never know what will break. For now things are running smooth with the website. If we migrate the version to PHP 7, we do not know if it will run or not. So everybody keeps postponing this sensitive task.
Fear not, I will guide you through this migration journey. I have done it for many shopping cart, financial domain and critical websites. I have sound experience doing this and you can bank on me. I will present you my experience doing these migrations.
I will guide you for the migration of the PHP application or website only. Upgrading the server environment like Apache version or the installed PHP version can be dealt with another article. It is a sysadmin thing.
If you are on a shared web hosting server, you will have an option in your control panel. It should be a single click easy work. Otherwise your hosting provider will do it for you. You may have to raise a ticket to get it done. Unless if you are in a dedicated server environment, you need not worry about.
Whatsoever, migration of the website or the PHP application should be done by you. It is not in the hosting provider or sysadmin’s scope. It should be done by the PHP developer.
Why now? What is the necessity to migrate PHP 5.6 to PHP 7 now? Before going into why, you should know about the PHP versions, their support duration and EOL details. It will give you the answers.
PHP 5.6 version active releases ended in early 2017 and reached its end of life (EOL) by 2018 end. That was once upon a time and long long ago. After PHP 5.6, we had PHP 7.0, 7.1, … and the current live version is 7.4
My longtime client recently forward an email he got from his hosting provider. His website is hosted with a popular shared hosting server.
The hosting provider has given ten days time to upgrade from PHP 5.6 to PHP 7.2 Even they have asked to migrate PHP 7.0 and PHP 7.1 to PHP 7.2 If the upgrade is not done within the given time frame, the hosting provider will upgrade the PHP version to 7.2 themselves.
This timeframe is to allow migrate the website to be compatible with 7.2. The control panel allows to change the PHP versions back and forth.
If you are in a shared hosting server environment, you will be forced to migrate anytime soon. You better make the move yourself, so that you can plan and execute at your convenience.
If there is one reason that stands on top of everything is security. There are many vulnerabilities that are being exposed to public daily. When there is a known vulnerability, PHP team will release a fix.
But if the PHP version has reached it EOL, then there will not be a release. Your website will stand exposed inviting the hackers. So it is important to migrate your website to a PHP version that is being supported. Upgrade your old PHP now!
There are numerous studies published and circulated widely. PHP 7 has, “100%+ performance gain on most real-world applications” says Rasmus Lerdorf (Ref: http://talks.php.net/fluent15#/php7) This is from his slides from PHP 7 talk at fluentconf. The good performance due to low latency is widely acknowledged.
So how does good performance help your website? For one second lag, you will loose a minimum of 10% visitors. Search engines give priority to fast loading websites. Are these two reasons not enough?
As published by Christian Vigh, PHP 7 is faster by a whooping 400% than PHP 5.2
Developers should be armed with good set of tools. When the language gives a good set of features, that enables the developer to produce a good product. Following are some of the features that are available in PHP 7.
This is the key thing to focus on website migration. You might have used a feature that is available only in the lower version and removed in the newer version. Here is a list of backward incompatible changes between PHP 5.6 and PHP 7.0
The above list is a summary only. Go through Ref: https://www.php.net/manual/en/migration70.incompatible.php for the complete list.
So you are going to move forward. Know about what you should not use going forward. If you have already used the deprecated features, then it is better to migrate them also. Here is a list the deprecated list.
Comments to “How to Migrate Website from PHP 5.6 to PHP 7”
Could you please suggest an IDE for PHP ?
Thanks in advance
Good free option is “Eclipse IDE for PHP developers”. PhpStorm is good but not free.
Notepad++ is a light-weight alternative. But you need to boost it up with plugins and extensions.
I use VIM, it is extraordinary. Not only for PHP, it is like a Swiss army knife. But has got a learning curve.
I mostly prefer vscode. It’s lighweight and lots of features are available via plugins.
Did you mean this https://www.vim.org/ by VIM ?
Yes Rinto, correct.
Like always again, your articles are top! Very informative.
Welcome Rony, thank you for the nice words.
This migration drove me nearly insane, with one specific page of mine that was working 100% on 5.6, and crashed on php7. After a looooong time, i figured out that when you start a new page with php7, the ” <?php " has to be on the first line and far left of the page. Mine was on line 2 – oversight on my side.
No Neels, “<?php has to be on the first line and far left of the page.” there is no such condition in PHP7. You might have had some other issues. Try it out with a simple PHP hello world script. It should work!
When I update my PHP version from 5.6 to 7.4, I no longer see the text part of the site. What should I look to update?
It should be a specific issue to the PHP file you have in your website. If you can give more details I can help.
I am a newbie to PHP and I want to migrate a website build on php 5.6 to 7.4. How to do.
You need to start with preparing a checklist. This article will help you with that. Go through each item and work on it one by one.