Code it
4.6K views | +0 today
Follow
Code it
This is a curated resource for programmers and software architects. It is regularly updated with Articles, Hacks, How Tos, Examples and Code.
Curated by nrip
Your new post is loading...
Your new post is loading...
Scooped by nrip
Scoop.it!

What makes PHP 7 so special ? 5 New Features in #PHP7

What makes PHP 7 so special ? 5 New Features in #PHP7 | Code it | Scoop.it

1. SPEED!

The developers worked very hard to refactor the PHP codebase in order to reduce memory consumption and increase performance. And they certainly succeeded.

Benchmarks for PHP 7 consistently show speeds twice as fast as PHP 5.6 and many times even faster! 

2. Type Declarations

Type declarations simply means specifying which type of variable is being set instead of allowing PHP to set this automatically. PHP is considered to be a weak typed language. In essence, this means that PHP does not require you to declare data types. 

3. Error Handling

The next feature we going to cover are the changes to Error Handling. Handling fatal errors in the past has been next to impossible in PHP. A fatal error would not invoke the error handler and would simply stop your script. On a production server, this usually means showing a blank white screen, which confuses the user and causes your credibility to drop. It can also cause issues with resources that were never closed properly and are still in use or even locked.

 

In PHP 7, an exception will be thrown when a fatal and recoverable error occurs, rather than just stopping the script. Fatal errors still exist for certain conditions, such as running out of memory, and still behave as before by immediately stopping the script. An uncaught exception will also continue to be a fatal error in PHP 7. This means if an exception thrown from an error that was fatal in PHP 5 goes uncaught, it will still be a fatal error in PHP 7.

 

4. New Operators

Spaceship Operator

PHP 7 also brings us some new operators. The first one we’re going to explore is the spaceship operator. With a name like that, who doesn’t want to use it? The spaceship operator, or Combined Comparison Operator, is a nice addition to the language, complementing the greater-than and less-than operators.

Null Coalesce Operator

Another new operator, the Null Coalesce Operator, is effectively the fabled if-set-or. It will return the left operand if it is not NULL, otherwise it will return the right. The important thing is that it will not raise a notice if the left operand is a non-existent variable.

5. Easy User-land CSPRNG

What is Easy User-land CSPRNG?

User-land refers to an application space that is external to the kernel and is protected by privilege separation, API for an easy to use and reliable Cryptographically Secure PseudoRandom NumberGenerator in PHP.

Essentially secure way of generating random data. 

 

read the original article at https://blog.teamtreehouse.com/5-new-features-php-7

 

No comment yet.
Scooped by nrip
Scoop.it!

Upgrade WordPress to PHP 7: How to Do It Safely

Upgrade WordPress to PHP 7: How to Do It Safely | Code it | Scoop.it

To upgrade WordPress to PHP 7, the process itself is easy.

 

In this article, we'll teach you how to make the switch and upgrade WordPress to PHP 7 the right way.

 

If you have full privileges on your server, you can upgrade WordPress to PHP 7 using your command line. On the other hand, if you’re on shared or managed hosting, you’ll probably have to ask your provider’s support team to upgrade your site manually.

 

In either case, the actual process is straightforward. The problem is that if you don’t take any precautionary measures, you run the risk of breaking elements of your site that don’t play nicely with PHP 7. That’s why we’re partial to a different approach that enables you to eliminate most of the risk involved.

 

Step #1: Back up your website

Step #2: Create a local staging copy of your site

There are plenty of ways to create a staging copy of your website, Try Local by Flywheel because it’s easy to set up. Plus, you don’t need to be a Flywheel customer to get the app. Just go to the website, fill out a short form, and download the tool.

Step #3: Test your staging site

Step #4: Upgrade your live site to PHP 7

There are two ways to approach it, depending on your host:

 

  1. If you use a Virtual Private Server (VPS) or any other hosting option that gives you full control, you can upgrade WordPress to PHP 7 from the command line.
  2. If your host doesn’t give you this level of access, you can ask them to upgrade you to the latest version through their support system.

 

When you’re done, be sure to test your site’s performance again (just to be safe). 

 

references:  

 

https://themeisle.com/blog/upgrade-wordpress-to-php-7/

 

https://wpengine.com/resources/upgrading-to-php-7/

 

 

 

 

nrip's insight:
You must upgrade your Wordpress sites to run on PHP7.
 
As mentioned earlier, security updates to PHP5+ branches will end on December 31, 2018.
 
Ask/Urge/Force your website developers, web managers, website hosts to move your sites to run on PHP7+ 
 
 

 

 
No comment yet.
Scooped by nrip
Scoop.it!

Migrating your Development Environment from PHP 5+ to PHP 7

Migrating your Development Environment from PHP 5+ to PHP 7 | Code it | Scoop.it

Many PHP applications are still running on PHP 5.x, not ready to take full advantage of the awesome features that PHP 7 offers.

 

A lot of developers have not made the switch because of certain fears of compatibility issues, migration challenges and the strange awkward feeling that migrating will take away a big chunk of their time.

 

In this tutorial, you'll learn how to upgrade your PHP 5 application to PHP 7 starting from upgrading your development environment.

 

Mac OS X

If you are a fan of Homebrew, you can install PHP 7.0 via homebrew like so:

brew tap homebrew/dupes brew tap homebrew/versions brew tap homebrew/homebrew-php brew unlink php56 brew install php70

If you were using PHP 5.6, then you should unlink the old PHP by running brew unlink php56 else unlink whatever version is present before you go ahead to install PHP 7.0.

Another option is to install it via curl on your terminal like so:

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

Windows

If you are fan of WAMP or XAMPP, then you can just download the latest versions of the software. It comes packaged with PHP 7.0.

Download and install the last/latest version

Another option is to download the PHP 7.0 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

Note: You can check out how to install PHP 7 and Nginx here, and manually build memcached module for PHP 7.

 

 

read the steps for the other OS's as well as other details in the original article at https://auth0.com/blog/migrating-a-php5-app-to-php7-part-one/

 

No comment yet.