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

Laravel News:
Homestead now with PHP 7 support
Oct 02, 2015 @ 10:52:41

In a quick post on the Laravel News site they point out that the Laravel Homestead virtual machine now has support for PHP 7:

Laravel Homestead just received a new update with support for PHP 7 which is due out this month.

If you are already using the PHP 5.x Homestead box, you can upgrade your installation to PHP 7.0 by cloning the php-7 branch of the laravel/homestead repository into a new folder.

With two other simple steps you can quickly upgrade your box to be running PHP 7 - updating the Homestead.yml configuration and running a vagrant up. You can find out more information about this update in the official documentation.

tagged: laravel homestead php7 support upgrade configuration vagrant

Link: https://laravel-news.com/2015/10/homestead-now-with-php-7-support/

PHP 7.0.0 RC 4 Released
Oct 01, 2015 @ 10:45:36

The main php.net site has officially posted the latest release candidate version for the upcoming PHP 7 version: Release Candidate 4. It's now available for download and testing.

The PHP development team announces the immediate availability of PHP 7.0.0 RC 4. This is the ninth pre-release of the new PHP 7 major series. All users of PHP are encouraged to test this version carefully, and report any bugs and incompatibilities in the bug tracking system. [...] PHP 7.0.0 RC 4 contains fixes for 22 reported bugs and over 100 commits with various improvements.

As always, you can download this latest pre-release version for testing from the QA downloads page or windows.php.net/qa for the Windows binaries. If you're interested in the full list of changes, check out the NEWS file for updates.

tagged: language release releasecandidate php7rc4 php7 qa test

Link: http://php.net/archive/2015.php#id2015-10-01-1

Lorna Mitchell:
New in PHP 7: null coalesce operator
Sep 30, 2015 @ 10:51:52

Lorna Mitchell has a post to her site talking about a new addition to PHP in the upcoming major release of PHP 7 - the null coalesce operator. Despite its slightly confusing name, the operator is very handy for certain use cases with the ternary syntax.

Not the catchiest name for an operator, but PHP 7 brings in the rather handy null coalesce so I thought I'd share an example. In PHP 5, we already have a ternary operator, which tests a value, and then returns the second element if that returns true and the third if it doesn't. [...] There is also a shorthand for that which allows you to skip the second element if it's the same as the first one.

[...] In PHP 7 we additionally get the ?? operator which rather than indicating extreme confusion which is how I would usually use two question marks together instead allows us to chain together a string of values.

She includes an example of this new operator in use, chaining together a simple expression and showing the resulting output. It's a little confusing at first, but then if you remember it reads left to right it clears it up a bit.

tagged: null coalesce operator php7 feature example

Link: http://www.lornajane.net/posts/2015/new-in-php-7-null-coalesce-operator

Zend Developer Zone:
PHP 7 Quick Overview
Sep 21, 2015 @ 13:51:26

On the Zend Developer Zone they've posted an article talking about the upcoming major version of PHP, PHP 7, and what you can expect from it. It's a brief overview of the new features and functionality included in this big update.

PHP7 is around the corner. According to the wiki time table if everything goes well, it is expected to be released in November 2015. Many of us are excited to learn the language level features and it’s performance.

The article touches on the highlights of:

  • Performance boosts
  • Null Coalesce Operator
  • Scalar Type Hints
  • Weak type mode
  • Strict mode
  • Handling Exceptions
  • Return Type Declaration
  • Reserve More Types in PHP 7
  • Timezone warning

There's a lot of new things coming, so check out this guide for a quick overview and to get up to speed before it's here.

tagged: php7 overview introduction list feature improvement

Link: http://devzone.zend.com/6656/php-7-quick-overview/

Zend Developer Zone:
Introducing PHP 7 Express
Sep 18, 2015 @ 10:54:48

In a post on the Zend Developer Zone they've introduced a new offering from Zend as a part of their Zend Studio IDE - PHP 7 Express. This tool makes it easy to migrate your code to a working state with the upcoming PHP 7 release.

The PHP 7 revolution is well upon us and at the end of the year we should be seeing an official release. To help you prepare for the expected changes, the upcoming version of Zend Studio – Zend Studio 13, includes a new migration tool called PHP 7 Express. PHP 7 Express scans your PHP code for potential compatibility issues with PHP 7 and supplies you with all the information you need to get your projects ready for migration to PHP 7.

They give an example of refactoring as it relates to the uniform variable syntax changes and removing deprecated function calls. They walk you through the use of the tool (inside the IDE) and show an example of the results, how you can jump to the code for each of the issues listed and the recommendations it provides to correct it.

tagged: zend zendstudio php7express ide feature php7 optimize fix tool

Link: http://devzone.zend.com/6647/introducing-php-7-express/

PHP 7.0.0 RC 3 Released
Sep 17, 2015 @ 09:04:35

The PHP.net site has officially announced the release of PHP 7.0.0 RC3 the latest Release Candidate for this upcoming major version. This is a development preview and is not intended for production use.

The PHP development team announces the immediate availability of PHP 7.0.0 RC 3. This is the eighth pre-release of the new PHP 7 major series. All users of PHP are encouraged to test this version carefully, and report any bugs and incompatibilities in the bug tracking system.

[...] This release provides a noticeable new Opcache feature which makes possible to move PHP code pages into the huge memory pages. It can be enabled with opcache.huge_code_page=1 in php.ini and can bring about 2% performance gain on supported platforms. Please help us to test this feature by enabling it and providing feedback.

They also list out several of the other features now included in the release such as:

  • improved overall performance
  • migrating some Fatal errors to Exceptions
  • the combined comparison operator ("spaceship")
  • scalar and return types
  • anonymous classes

As always you can download this latest version from the QA downloads page or here for the Windows binaries. The next release (RC4) will be coming October 1st, so be sure and test out RC3 on your systems and code and report those bugs!

tagged: php7 language release releasecandidate rc3 php7rc3

Link: http://php.net/archive/2015.php#id2015-09-17-2

Zend Developer Zone:
A new type of PHP, part 2: Scalar types
Sep 16, 2015 @ 09:09:26

The Zend Developer Zone has posted the second part of their series (from community member Larry Garfield) about scalar types in PHP 7, one of many features in this "coming soon" release. You can find part one of the series here.

In our last installment, we talked about the benefits of more robust variable typing in PHP 7, and specifically the new support for typed return values. That is already a big boon to the maintainability of our code, but PHP 7 goes a step further. So far, we’ve only talked about typing against classes and interfaces. We’ve been able to type against those (and arrays) for years. PHP 7, however, adds the ability to type against scalar values too, such as int, string, and float.

But wait. In PHP, most primitives are interchangeable. [...] Much the same as return types, scalar types offer greater clarity within the language as well as the ability to catch more bugs earlier. That, in turn, can help encourage more robust code in the first place, which benefits everybody.

He starts by looking at the four new types that have been added in PHP 7: int, float, string, and bool. He includes a code example showing each of them in use on class interfaces and functions. He steps through the code example, explaining how the return type checking is handled for each instance. He also talks about how return type hinting can also benefit static analysis tools, allowing them to potentially find bugs in return values easier than before. Finally he covers strict mode, the method for enforcing types in your code and preventing PHP from doing any "magic" type switching for you. He also includes a code example of this functionality and how, with it enabled, it would have caught an error in his example on a integer vs string input.

tagged: scalar type hints introduction php7 strict example

Link: http://devzone.zend.com/6622/a-new-type-of-php-part-2-scalar-types/

Dodge the thundering herd with file-based Opcache in PHP7
Aug 31, 2015 @ 11:55:37

The Tideways.io site has posted a tutorial showing you how to "avoid the thundering herd" of incoming requests to your application using a file-based PHP 7 opcode cache to reduce load and increase performance on your site.

In the last blog post about Fine-Tuning Opcache Configuration I mentioned the thundering herd problem that affects Opcache during cache restarts. When Opcache is restarted, either automatically or manually, all current users will attempt to regenerate the cache entries. Under load this can lead to a burst in CPU usage and significantly slower requests.

[...] In Rasmus talk at FrOsCon 2015 (Video at 12:30, Slides), he showed the persistent secondary file-based cache Opcache gets in PHP 7. It can read the generated opcodes from disk instead of having to recompile the code after cache restart. This happens only when the compiled opcaches are not found in shared memory.

They talk about the benefits that this caching can provide, not only to web-based applications but also to command line scripts. There's a mention of possible security issues if an attacker is able to read/write to the cache files (but permissions can help that). The post ends with how to install it on your own PHP 7 instance, using the --enable-opcache-file flag on compilation.

tagged: thunderherd opcode cache problem php7 example commandline

Link: https://tideways.io/profiler/blog/dodge-the-thundering-herd-with-file-based-opcache-in-php7

PHP 7 Up and Running (Video Series)
Aug 28, 2015 @ 10:38:14

The Laracasts site has posted a set of videos that can help you learn all about PHP7 and get you up to speed before this next major release is available for download (well, a stable release anyway).

Slated for release in October, 2015, PHP 7 brings a wealth of new features, bug fixes, and performance improvements. If you're curious, come with me, as I demonstrate what's new!

The videos cover some of the major new features coming to the language including:

More videos are coming too, including one already listed showing how to use anonymous classes. Keep an eye on this series to learn all about PHP 7 before it's even released.

tagged: php7 video series introduction major version tutorial

Link: https://laracasts.com/series/php7-up-and-running

BitExpert Blog:
Running pdepend on PHP7
Aug 18, 2015 @ 09:57:19

On the BitExpert blog there's a post that shows you how to use the pdepend tool on PHP7, an automated tool that shows you the "quality of your design in the terms of extensibility, reusability and maintainability".

Being a good citizen of the PHP community we do test out internal libs against the current PHP7 codebase. So far we had no issues but then at one day one of our Jenkins PHP7 jobs failed. After investigating a bit it turned out that the problem was not part of our codebase but part of of pdepend. The pdepend process died with the error message that "T_CHARACTER and T_BAD_CHARACTER are no longer defined" which is true. The error was already reported as an issue on Github.

Unfortunately, as the problem here is a change to the core PHP language itself, there's not much of a workaround other than to just not run those certain jobs. He outlines how they handle detecting the tests that have problems, but only when run on PHP7. This allows them to run all of the tests and allow the automated system do to its work. When/if the problem is fixed in pdepend, all that's needed is to remove this one check and they're good to go.

tagged: pdepend phpdepend php7 skip test version error github issue

Link: https://blog.bitexpert.de/blog/running-pdepend-on-php7/