Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

TutsPlus.com:
Upgrading Your Linux Server to PHP 7.0
Dec 07, 2016 @ 11:47:25

The TutsPlus.com site has a new tutorial posted showing you how to upgrade your Linux server to run PHP 7.0, the latest major release of the PHP language.

PHP 7 was released last December. Once you've tested your code locally to run on it, it's time to upgrade your production server. Generally, I found that most of my sites run well on it.

However, I suspect that not many sites have upgraded yet. It's often safer and easier to stay on older releases. [...] But PHP 7 has now been out for nearly a year.

In today's episode, I'll walk you through my recommended approach to upgrading to PHP 7 on Ubuntu 14.x and resolving problems with PHPMyAdmin, which a lot of early upgraders ran into.

He starts by helping you identify any customizations that you might have related to PHP 5, specifically related to configuration options. He then provides the commands to remove PHP 5 packages from the system and add in the "ondrej/php" PPA for apt-get as the source for the PHP 7 packages. After a quick apt-get cleanup, he includes the commands to install the "php7" packages, enable a few extra modules and getting phpMyAdmin back up and in working order.

tagged: upgrade server php7 php5 ppa aptget phpmyadmin tutorial

Link: https://code.tutsplus.com/tutorials/upgrading-your-linux-server-to-php-7--cms-27583

Blackfire.io Blog:
PHP 7 performance improvements (1/5): Packed arrays
Nov 17, 2016 @ 11:06:53

On the Blackfire.io blog a new tutorial has been posted by Julien Pauli looking at some of the features of PHP 7 and how they relate to the overall performance in this latest major version of the language. In this first post in the series Julien talks about packed arrays.

This blog series will show you what changed inside the Zend engine between PHP 5 and PHP 7 and will detail how you, as a developer, may effectively use the new internal optimizations. We are taking PHP 5.6 as a comparison basis.

[...] Packed arrays is the first great PHP 7 optimization. Packed arrays consume less memory and are a bit faster in many operations than traditional arrays.

He gets into the specifics of how the packed arrays work, mentioning the internal optimization the language does, requiring no intervention in user-land code. He shows the difference between the PHP 5.6 performance and PHP 7 using the Blackfire.io tool - a difference of about a 70% gain.

tagged: php7 blackfire performance packed array feature optimize

Link: https://blog.blackfire.io/php-7-performance-improvements-packed-arrays.html

Tumblr Engineering Blog:
PHP 7 at Tumblr
Nov 11, 2016 @ 13:07:07

The Tumblr Engineering blog has a new post with details about how they made the switch to PHP 7 in their previously PHP 5 codebase (and some of the things they learned along the way).

At Tumblr, we’re always looking for new ways to improve the performance of the site. This means things like adding caching to heavily used codepaths, testing out new CDN configurations, or upgrading underlying software.

Recently, in a cross-team effort, we upgraded our full web server fleet from PHP 5 to PHP 7. The whole upgrade was a fun project with some very cool results, so we wanted to share it with you.

They start off with the timeline of events, starting with the original hackday project out through the final PHP 7 deployment in production less than a year later. They cover some of the testing methods they employed during the transition and the impact of the update on their application on request latency, CPU load and memory usage. They wrap up the post talking about some of the PHP 7-specific things they made use of in their update including anonymous functions and scalar type hinting.

tagged: tumblr php7 update php5 hackday project testing performance

Link: https://engineering.tumblr.com/post/152998126990/php-7-at-tumblr

Chike Mgbemena:
PHP 7 In-Depth Look
Nov 04, 2016 @ 11:58:51

Chike Mgbemena has posted a great guide for those out there still getting familiar with what PHP 7 has to offer and things to watch for when migrating your PHP 5.x code up to this latest version.

PHP 7 was released on 03 Dec 2015, and so many people have not yet started using or learning about the awesome features it has. I wrote this post to give a breakdown of the features released with PHP 7 for those that have not yet learnt about them and even if you know it, you might still learn something from this post.

Rasmus Lerdorf (creator of PHP) claims that apps running PHP 7 performance is improved by 100% or more. Memory usage is lower also, so if you are running a lot of servers, PHP 7 is an essential upgrade. One of the big changes in PHP 7 is the refactored ZEND Engine(PHPNG) which is now faster, memory usage reduced and a “green” version of PHP which makes you run less hardware to run your code.

He starts with a list of things that have been removed from PHP 7 including the MySQL extension (not mysqli), posix regular expression handling and the deprecation of the "salt" option in password hashing. He goes on to talk about some of the new things that come with PHP 7 including:

  • the "spaceship" operator
  • allowing constants to be defined as arrays (previously just strings)
  • the random_bytes and random_integer functions

He also covers one of the most major changes in PHP 7: the inclusion of type hinting and checking, generators, error handling updates and a few other miscellaneous changes.

tagged: php7 indepth language changes guide

Link: http://chikemgbemena.com/2016/10/29/php-7-in-depth-look/

SitePoint PHP Blog:
A Crash Course of Changes to Exception Handling in PHP 7
Nov 02, 2016 @ 11:10:09

The SitePoint PHP blog has a tutorial they've posted that shares information about changes in the exception handling in PHP 7 and what you need to know about them (and potentially change in your application).

Exception handling saves your code in the most unusual circumstances. PHP 7 has introduced two new classes that assist a developer in handling errors with ease, and that’s what we’ll look at in this post. Before the introduction of these classes in PHP 7, exception error classes were written to handle the different types of errors.

They start with the new "Throwable" interface that's the base for both the "Exception" and "Error" class types. From there the article talks about the "Error" type, showing the list of new errors included in PHP 7: ArithmeticErrors, TypeError, ParseError and AssertionError. It also includes code examples for each showing when they'd be thrown and how you can catch them (more specifically than just catching all exceptions).

tagged: changes exception handling php7 crashcourse

Link: https://www.sitepoint.com/a-crash-course-of-changes-to-exception-handling-in-php-7/

Chike Mgbemena:
Abstract Syntax Tree/Uniform Variable Syntax in PHP 7+
Nov 01, 2016 @ 11:57:01

Chike Mgbemena has a new post to his site looking at PHP 7 and the abstract syntax tree and uniform variable syntax changes that came along with it.

On my previous post (PHP 7 In-depth Look), I discussed in-depth about the features of PHP 7 (you can read it here if you have not). In this post, I am going to be talking about The Abstract Syntax Tree(AST)/Uniform Variable Syntax in PHP 7+.

PHP 7 introduced a new layer which is called the Abstract Syntax Tree(AST) which helps in decoupling the process of parsing from the pseudo-compile process. Note that this new layer does not have much impact on performance but it make the syntax uniform. Uniform variable syntax/abstract syntax tree aims to establish internally consistent variable syntax, references are accessed from left to right instead of right to left.

He goes on to talk about dereferencing, how it changed from the PHP 5 handling and what IIFEs have to do with it. Some sample code is included showing some of his points and how PHP 7 interprets things slightly different than PHP 7.

tagged: abstractsyntaxtree ast uniform variable syntax php7 php5

Link: http://chikemgbemena.com/2016/11/01/abstract-syntax-treeuniform-variable-syntax-in-php-7/

Simon Holywell:
Importing and aliasing PHP functions
Oct 24, 2016 @ 11:34:29

In this recent post to his site Simon Holywell continues his look at namespacing in PHP with a look at importing and aliasing specific functions, not the entire class.

As a follow on to my short post about namespaces and functions from a year ago I thought it would be worth covering importing a specific function and aliasing functions via namespace operators too. This has been possible since PHP 5.6, but there is a nice addition in PHP 7 I’ll cover towards the end.

He starts with a refresher example of pulling in a namespace and using a method with the "use" statement. Following this he shares an update that just imports the one method via a "use function" call rather than the entire class/namespace. He again refactors this into something more usable (the original method name is quite long) with an alias. He then ends the post with the PHP 7 only trick using the braces to define grouped namespace handling (however, this doesn't allow for function level aliasing).

tagged: import alias function namespace grouping php7 tutorial

Link: https://www.simonholywell.com/post/2016/10/importing-and-aliasing-php-functions/

StartTutorial.com:
5 New Features In PHP 7 That You Should Have A Look At
Oct 19, 2016 @ 09:43:05

If you've heard about the release of PHP 7 but aren't quite sure what it has to offer, check out this quick post on the StartTutorial site giving you a "top five" list of things this new version of the language has to offer.

But you must be wondering why PHP named its latest release PHP 7 and not PHP 6. Reason behind it is that, many of the PHP 6 releases were already implemented in PHP 5.3 and later, there was not really a proper reason just to change the name. What I am trying to say here is that we haven’t missed anything. Just to avoid the confusion with a dead project, PHP's latest release was named to PHP 7.

Is This Hype Valid for PHP 7? What It Actually Brings Forth for the Developers? Hop on and let’s take a deeper dive. Let's check out what new features PHP 7 has to offer. And what improvements those features will bring forth.

Their top five list covers some of the major improvements in the language:

  • Speed Improvement
  • Implementation of Type Declarations
  • Implementation of Error Handling
  • New Operators
  • CSPRNG Functions

There's a bit of explanation of each item on the list but you'll definitely want to refer to the PHP manual for more details and specifics on what changed in PHP 7.

tagged: php7 feature top5 list speed typing errors operators csprng

Link: https://www.startutorial.com/articles/view/5-new-features-in-php-7-that-you-should-have-a-look-at

Dailymotion.com Engineering Blog:
PHP 7 deployment at Dailymotion
Oct 18, 2016 @ 13:53:51

On the Dailymotion.com Engineering blog there's a recent post detailing their experiences moving their services to PHP 7 and some of the discoveries they made along the way.

In march 2015, we started to think that code refactoring and architecture improvements, will not be the only way to optimize the response time on dailymotion.com. This is the core problem of websites with high load : “how to scale without investing too much in people/servers”.

They started out by looking into Facebook's HHVM project to potentially replace the default PHP interpreter with a better performing core. They mention incompatibilities they discovered and some of the results in testing it on a handful of servers in production. They had some time to play with things so they waited until PHP 7 was officially released and tried that to make an equal comparison. In the end, they ultimately chose to go with PHP 7 as it was the route with less "friction" and work on changes for their current codebase. The post also includes graph output of some of the improvements they saw when

tagged: dailymotion engineering php7 deployment experience

Link: http://engineering.dailymotion.com/php-7-deployment-at-dailymotion/

SitePoint PHP Blog:
Quick Intro: PhpCompatibility for PHPCS – Are You PHP7 Ready?
Sep 27, 2016 @ 11:13:17

The SitePoint PHP blog has a quick tutorial posted helping you get your application PHP 7 ready with the help of the PhpCompatibility "sniffs" for the widely used PHP_CodeSniffer tool.

Sooner or later, there will come a time when you will need to migrate your projects to different PHP versions. How will you check if you’re compatible with a PHP version different to the one you’ve been developing on?

One possibility is always to install the version of PHP we want to migrate to, run php -l or something like PHPSA to check for syntax errors, check the PHP documentation for known issues with the migration and hope for the best. Or, we can use some available third party tools to check for PHP version compatibility in our projects.

The article then introduces the PHPCompatibility set of sniffs for PHP_CodeSniffer and installing them with a "git clone" in the right Standards directory. Also included are some basics for using PHP_CodeSniffer (like the command line options) and an example of some of the output from the compatibility check. The post wraps up with a real-life example using the PHPMailer codebase and testing it for PHP 5.6 readiness.

tagged: php7 codesniffer compatibility test codebase sniff

Link: https://www.sitepoint.com/quick-intro-phpcompatibility-standard-for-phpcs-are-you-php7-ready/