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

PHP Roundtable:
064: PHP 7 Source Code: A Deep Dive
Jul 12, 2017 @ 13:35:41

The PHP Roundtable podcast, hosted by PHP community member Sammy K Powers, has posted their latest episode: Episode #64 - PHP 7 Source Code: A Deep Dive. In this show Sammy is joined by Sara Golemon, a core language contributor and XHP.

We take a deep-dive into the underlaying structure of the the PHP source code and talk about the scanner, parser, the new AST layer (and the evil things we can do with it), and the Zend engine. Let's see how the PHP sausage is made!

You can catch this latest episode either through the in-page audio or video player, directly on YouTube or by downloading the mp3 directly. If you enjoy the episode, be sure to follow them on Twitter and subscribe to their feed to get updates when future shows are being recorded and are released.

tagged: phproundtable podcast ep64 php7 deepdive source code saragolemon

Link: https://www.phproundtable.com/episode/php-7-internals-scanning-parsing-ast-and-engine

Scotch.io:
What's New in Laravel 5.5
Jul 07, 2017 @ 13:07:47

The Scotch.io site has posted a new article sharing some of the new features and changes that are coming with Laravel 5.5, the next major release of the framework.

At the time of this writing, Laravel 5.5 is not released yet. It is slated, as the next major release, for release in July 2017. To play around with new features and changes, you need to grab the dev release of Laravel using this Laravel Installer command: laravel new project --dev

The article starts by pointing out that this version will require at least PHP 7.0, a supported and much more performant version of the language. It then covers the changes in this version including:

  • the reintroduction of the "Whoops" library for debugging/error handling
  • a change to vendor:publish to get a new provider prompt
  • email themes
  • automatic package discovery
  • error page design improvements
  • streamlined request validation
  • exception helper functions
  • model factory generators

Each of these items comes with screenshots or code examples showing the new feature at work. It also ends with a few miscellaneous updates mentioning changes in the CSRF handling and the return of a JSON stack trace for API calls.

tagged: laravel version feature update changes php7 v55 framework

Link: https://scotch.io/tutorials/whats-new-in-laravel-55

CloudWays Blog:
PHP 5.6 Vs PHP 7 – Performance Benchmarks With Laravel 5
Jun 16, 2017 @ 11:56:59

The CloudWays blog has posted an article sharing the results from some benchmarking they've done comparing Laravel 5 on PHP 5.6 versus PHP 7.

Laravel is rapidly becoming a popular choice for PHP projects. The framework has established its reputation after the release of version 5.x. In the same vein, PHP recently received a major update in the form of PHP 7.1.x.

It is an established fact that Laravel has a solid codebase and provides optimized performance for all lightweight and enterprise level applications. However no statistics about Laravel 5 benchmarks and its performance with PHP 5.6 and PHP 7 are widely available.

Using the Blitz testing tool and sample Laravel applications managed through CloudWays (on DigitalOcean), they benchmarked mean response times and the "hit rate" of the requested pages. Graphs are included of the results for both PHP 5.6 and PHP 7 and the post ends with a comparison of the results from the two scenarios with PHP 7 coming out on top.

tagged: cloudways laravel benchmark php56 php7 comparison blitz

Link: https://www.cloudways.com/blog/laravel-5-benchmarks-php-5-6-and-7/

Rob Allen:
Inserting binary data into SQL Server with ZF1 & PHP 7
May 22, 2017 @ 09:34:51

In an interesting mix of "old" and "new" Rob Allen as shown in this new post to his site how to push binary data into a SQL Server database from a Zend Framework v1 application.

If you want to insert binary data into SQL Server in Zend Framework 1 then you probably used the trick of setting an array as the parameter's value with the info required by the sqlsrv driver as noted in Some notes on SQL Server blobs with sqlsrv.

[...] Working through the problem, I discovered that this is due to Zend_Db_Statement_Sqlsrv converting the $params array to references with this code. The Sqlsrv driver (v4) for PHP 7 does not like this! As Zend Framework 1 is EOL, we can't get a fix into upstream and update the new release, so we have to write our solution.

He includes the code for the "hack" that you'd normally have to do to push the binary data into the database. Zend Framework v1 is EOL (end of life) so the Zend_Db_Statement_Sqlsrv class can't be updated. Instead, he writes his own replacement, creating a new adapter specific to the application that handles the input as the SQL Server driver is expecting. He then updates the application configuration to force the new adapter to be used when the ZF1 application needs to connect to the SQL Server database.

tagged: insert binary data sqlserver zendframework php7 tutorial adapter

Link: https://akrabat.com/inserting-binary-data-into-sql-server-with-zf1-php-7/

Symfony Blog:
Preparing your Applications for PHP 7 with Symfony Polyfills
May 19, 2017 @ 11:07:50

The Symfony blog has posted an article showing you how to prepare your applications for a migration to PHP 7 with the help of various polyfill libraries. These libraries make it possible to use PHP 7 functionality in non-PHP 7 applications if the function in use isn't defined.

According to the May 2017 PHP Stats, 53% of PHP developers use PHP 7.0 or 7.1, but only 10% of Composer packages require PHP 7.0 or higher. In fact, 1 in 4 packages still require PHP 5.3, which is used by less than 1% of developers.

[...] Upgrading your development machines is usually a simple task, but upgrading the rest of the infrastructure (servers, tools, etc.) usually requires more resources. This is where Symfony Polyfills can help you preparing the code of your application for PHP 7.

The article briefly explains what polyfills are and how to load in the current Symfony set via a Composer install. There've provided functionality for PHP versions 5.4 through 5.6 as well as PHP 7.0 and 7.1 to ensure you have the most up to date functionality at your fingertips.

tagged: php7 application symfony polyfill library functionality composer tutorial

Link: http://symfony.com/blog/preparing-your-applications-for-php-7-with-symfony-polyfills

Jordi Boggiano:
PHP Versions Stats - 2017.1 Edition
May 09, 2017 @ 09:16:21

Jordi Boggiano, author and lead developer on the Composer project has posted his latest updates sharing the PHP version statistics for the first part of 2017.

It's stats o'clock! See 2014, 2015, 2016.1 and 2016.2 for previous similar posts.

A quick note on methodology, because all these stats are imperfect as they just sample some subset of the PHP user base. I look in the packagist.org logs of the last month for Composer installs done by someone. Composer sends the PHP version it is running with in its User-Agent header, so I can use that to see which PHP versions people are using Composer with.

He starts with the differences between now and the last time he ran the stats with a nice trends towards the PHP 7.x releases, especially PHP 7.1. He shares some graphs of the overall version distribution and a time-related graph showing changes in usage over time. Finally, he ends the post the same way as the others showing requirements of packages and how they've changed since the last update (what version a package requires).

tagged: version statistics results graph time php7 2017

Link: https://seld.be/notes/php-versions-stats-2017-1-edition

Nikita Popov:
PHP 7 Virtual Machine
Apr 17, 2017 @ 17:42:47

Nikita Popov has a new post to his site sharing a look behind the curtain of how the PHP 7 virtual machine works, the latest version in the Zend Virtual Machine that powers the language.

This article aims to provide an overview of the Zend Virtual Machine, as it is found in PHP 7. This is not a comprehensive description, but I try to cover most of the important parts, as well as some of the finer details.

This description targets PHP version 7.2 (currently in development), but nearly everything also applies to PHP 7.0/7.1. However, the differences to the PHP 5.x series VM are significant and I will generally not bother to draw parallels.

Most of this post will consider things at the level of instruction listings and only a few sections at the end deal with the actual C level implementation of the VM.

He then goes through many different points and piece of functionality in the VM and how they work including:

  • variable types
  • the stack frame layout
  • fetch modes
  • exception handling
  • finally handling
  • generators

There's lots of information here and it's definitely interesting to see what happens inside the language to create the fast and functional PHP 7 applications we have now.

tagged: virtualmachine php7 zend detail behindthescenes example

Link: http://nikic.github.io/2017/04/14/PHP-7-Virtual-machine.html

CloudWays Blog:
Stefan Priebsch Talks About ThePHP.Cc, His Experience With PHP Development, PHP 7 &
Apr 14, 2017 @ 12:50:39

The CloudWays blog has posted another in its series of interviews with members of the PHP community. In this latest article they talk with Stefan Priebsch of thePHP.cc (a consulting company) and some of his experiences, past and present, in the world of PHP.

Today, We are honoured to have Stefan Priebsch for this interview. He is a cofounder of thePHP.cc, a well known PHP consulting firm. He is also an entrepreneur, university lecturer and a thought leader in modern software application architecture. Stefan specializes in PHP powered enterprise applications and has built an enviable reputation as one of the best trainers in Germany.

Additionally, Stefan speaks regularly at international PHP conferences and wrote a book PHP 7 Explained with Sebastian Bergmann and Arne Blankerts. In this interview, he talks about his career, PHP 7 ebook and the latest developments in the industry.

In the interview Stefan answers questions about the benefits of the PHP 7.x releases, his work at thePHP.cc, his book, what development tools he uses and how he spends his free time. You can read his answers to these questions and more in the full interview.

tagged: cloudways interview stefanpriebsch thephpcc experience php7 book development

Link: https://www.cloudways.com/blog/stefan-priebsch-interview/

Exakat Blog:
Moving from array to class
Apr 12, 2017 @ 11:18:42

In a new post to the Exakat blog there's a proposal to replace uses of arrays with classes to make scripts more efficient and handle resources better behind the scenes.

Ever since I started using PHP, arrays have always been my friend. They are versatile, they have a wide range of functions, and they are easy to use. I kept using them versions after versions, and even with PHP 7.2, I still rely on them a lot. Over the years, classes have also made their way into my toolset. They have a different usage : classes are for complex data structures, for business logic. Simple data structures get an array. Until we tried what seemed impossible : a moving from an array to a class.

He mentions some of the recent changes in PHP 7 that make the use of classes over arrays a bit more advantageous. He then gets into how to take advantage of these efficiency benefits in moving from arrays to classes. He uses an example from his own work in the Exacat engine, how he performed the replacement and a small caveat he found when working with functions requiring array input. He ends the post with some of the other benefits from making the move including performance enhancements, readability and reduced memory usage.

tagged: array class performance difference tutorial php7

Link: https://www.exakat.io/moving-from-array-to-class/

Stefan Koopmanschap:
Sculpin and Docker
Mar 22, 2017 @ 12:49:05

Stefan Koopmanschap has written up a tutorial on his site introducing the use of Docker and Sculpin to create an easily reproducible and manageable blogging setup.

I've been running this blog on Sculpin for quite a while now, and I'm quite happy with how that works. We've been in a process of migrating some of our websites off a standard VPS towards a setup with Docker, Gitlab CI and Rancher. I've now migrated some websites, which is relatively easy, but most of those sites were dynamic PHP websites. Migrating a site that generates static HTML and running that is a slightly different thing. Here's how I ended up doing it.

First he covers his old setup - essentially the manual run of a shell command to generate the latest version of a the static Sculpin site. He decided to update the process and help makes things more automatic using Docker and a Gitlab pipeline flow. He then documents his attempts and configuration options as he built up the Docker configuration he wanted. This ultimately resulted in a Docker setup that installed PHP and Nginx to serve up the site, Composer to load in the required dependencies (like Sculpin) and the commands to "deploy" the latest version of the site publicly.

tagged: sculpin docker setup configuration tutorial dockerfile php7

Link: https://leftontheweb.com/blog/2017/03/18/sculpin-and-docker/