How to Migrating a PHP 5 to PHP 7
IT Training

How to Migrating a PHP 5 to PHP 7

How to Migrating a PHP 5 to PHP 7

PHP is best server-side scripting language for the web. Even so,PHP went for ten years without receiving a major version update. In fact many production PHP apps are currently running on either PHP 5.2,5.3,or 5.6.

PHP 7 has following features

  • Return and scalar type declarations
  • Better Unicode support
  • Null coalescing operator
  • Fatal error conversion to exceptions
  • Generator enhancement
  • Anonymous classes
  • Secure random number generator
  • Removal of deprecated features

Following steps need to upgrade from PHP 5 to PHP 7

  1. Choosing an IDE
  2. Code upgrade process
  3. Testing phase

Choosing an IDE

Choose IDE and set the environment to PHP 5.6 then open entire project in IDE and check for the errors and suggestions given by it to refactor the code.

Code to upgrade from PHP5 to PHP7

Set reporting errors and solve all the errors including notice errors and deprecated errors. Create an abstraction layer for database operations. Suppose codebase is large, than resolve the errors to make it work in PHP 7.0 and use the new features to simplify the code.

Testing phase

Maintain the logs for database errors and create the logs for PHP errors datewise. A new testing server create than continue testing during that testing period. Everything is okay; you may move it to production.

Now we discuss about upgrade your development environment to run PHP 7 on Ubuntu, CentOs, Windows and Mac OS machines.

Mac OS X

If you are a using of Homebrew, you can install PHP 7.0 via homebrew like this :

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew unlink php5.6
brew install php7.0

Using curl : curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0

Windows

If you are using of WAMP or XAMPP, then you can just download the latest versions of the software. It comes packaged with PHP 7.0 or download distribution for windows from http://windows.php.net/download#php-7.0.

Ubuntu

If you are running Ubuntu on your machine, especially around v14 and 15, you can install PHP 7.0 by running these commands:

sudo apt-get update
sudo add-apt-repository ppa:ondrej/php

sudo apt-get install -y php7.0-fpm php7.0-cli php7.0-curl php7.0-gd php7.0-intl php7.0-mysql

CentOS / Red Hat Enterprise Linux

If you are running CentOS or Red Hat Enterprise Linux operating system on your machine, you can install PHP 7.0 by running the following commands on your terminal.

sudo yum update
rpm-Uvh
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

sudo yum install php70w

sudo yum install php70w-mysql

Author: STEPS

Leave a Reply

Your email address will not be published. Required fields are marked *