PHP Annotated Monthly – May 2019
Please welcome the May edition of PHP Annotated Monthly. Inside we have all the latest news and material from the world of PHP. Read all about the PHP updates, Codeception, WordPress, and other releases. PHP 7.4 is shaping up with a few new RFC proposals accepted including arrow functions, Zend Framework becomes Laminas, news from Laravel, Yii, and Symfony, some async PHP stuff, useful tools, and a whole lot more!
⚡️ News & Releases
- PHP 7.3.5
- PHP 7.2.18
- PHP 7.1.29
- WordPress 5.2 “Jaco” — The release includes a significant security update which fixes a six-years-old issue: WP core updates are now cryptographically signed using Ed25519. You can find more details about this in Mitigating Supply-Chain Attacks Against 33% of the Internet post.
- Codeception 3.0 — Improved interactive shell, retry steps, PHPUnit 8 support, and other things.
- Zend Framework transitions to Linux Foundation — and has been renamed Laminas, to detach it from commercial brand Zend.
The new organization will include the Expressive microframework, Apigility, and ZF itself. Currently the repo only contains a bridge package laminas/laminas-zendframework-bridge with a special autoloader. The full transition will happen over next few months.
🐘 PHP Internals
- [RFC] Arrow Functions 2.0 — The proposal has passed the vote and is now accepted! We’ll get short closures in PHP 7.4. The original syntax
fn() =>is used and it also has automatic scope binding by value:
$y = 1; $fn = fn($x) => $x + $y;
So far arrow functions can only have a single statement. Multiline functions are part of the future scope and may be implemented later. The hack with the
andOperator = ($x) => ($y = 40) && $x + $y; console.log(andOperator(2)); // 42
$andOperator = fn($x) => ($y = 40) && $x + $y; var_dump($andOperator(2)); // bool(true)
But it is possible to do a workaround with array functions:
$multipleLines = fn($x) => array_slice([ $y = $x * 8, $z = $y + 8, $x + $y + $z ], -1); var_dump($multipleLines(2)); // int(42)
- [RFC] Deprecate PHP Short open tags — The proposal considered eliminating the tags
<?, but it faced a wave of resentment and arguments. And although it was accepted, it looks like the deprecation will be postponed.
- [RFC] Spread Operator in Array Expression — Almost unanimous voting makes it possible to use the
...operator in arrays.
$parts = ['apple', 'pear']; $fruits = ['banana', 'orange', ...$parts, 'watermelon']; // ['banana', 'orange', 'apple', 'pear', 'watermelon'];
Also it can help convert an iterator to an array instead of using
$array = [...$iter];
- [RFC] Allow throwing exceptions from __toString() — Nikita continues fixing “PHP Sadnesses” one by one. He is working on an old issue of throwing exceptions in a
__toString(). Another useful and not trivial improvement for PHP 7.4, which will save us from using workarounds like 1, 2.
- [RFC] Deprecate left-associative ternary operator — Almost all programming languages have the ternary operator calculated from right to left, but this is different in PHP it was a potential source of bugs. The proposal to deprecate left associativity is now accepted, and if a nested ternary is needed then the precedence should be explicitly declared with brackets.
1 ? 2 : 3 ? 4 : 5; // deprecated (1 ? 2 : 3) ? 4 : 5; // ok 1 ? 2 : (3 ? 4 : 5); // ok
- With all the accepted RFC’s PHP 7.4 is going to be amazing! Read a nice recap on what’s New in PHP 7.4.
- Derick Rethans has recorded a whole load of new episodes of PHP Internals News:
- pinba-server/pinba-server — Pinba server on PHP, that saves all the data to ClickHouse. Read more on the blog post: Statistics and monitoring of PHP scripts in real time.
- kalessil/production-dependencies-guard — Prevents dev-dependencies from being added into
requiresection of composer.json, and makes some other checks.
- twirphp/twirp — A PHP port of Twitch’s RPC framework Twirp. Introductory blog post.
- fe3dback/str — A strong typed string manipulation library with multibyte support.
- cycle/orm — A PHP DataMapper and ORM engine designed to work in long-running PHP applications. Documentation is in progress, but it is being compared to Doctrine and Eloquent.
- php-comrade/comrade-dev — Job scheduler & manager tool.
- jwage/changelog-generator — Generates a markdown changelog document from a GitHub milestone.
- krakjoe/parallel v0.9 — An extension from pthreads author Joe Watkins with a simplified interface for parallel code execution. Check out an example of using channels with parallel.
- lezhnev74/openapi-psr7-validator — Validates PSR-7 messages (HTTP request/response) against OpenAPI specifications
- saa-nl/zymfony-bundle — A set of components to migrate from Zend Framework 1 to Symfony 4.
- A week of Symfony #644 (29 April – 5 May 2019)
- Сontainerizing a Symfony application
- VanOns/laraberg — A port of Gutenberg block editor from WordPress to Laravel.
- aimeos/aimeos-laravel — Another e-commerce solution built on top of Laravel.
- 🎥 Laravel Core Adventures – On the inners of Eloquent
- 🎥 Getting Started with Event Sourcing in Laravel — using spatie/laravel-event-projector.
- 🔈 The Laravel Origin Story — An interview with Taylor Otwell where he talks about how he started Laravel and how it grew from a side-project into a business.
- 🔈 Taylor Otwell’s podcast Laravel Snippet #11, #12
- 🎥 Laravel Hangout — Taylor answers users’ questions live.
- Insolita/yii2-codestat — Yii 2 code stats calculator.
- omnilight/yii2-scheduling — A port of Laravel’s Schedule component for Yii 2.
- Preparing Yii for the long run — Now you can officially support the project financially. It’s very convenient for anyone who would like to contribute but don’t have enough time.
- Mehdi Achour joins Yii core team
- Fast release cycle — The main framework package release is now tagged at about once a month if there have been changes since the last release.
🌀 Async PHP
- RESTful API with ReactPHP: Basic HTTP authentication, and authentication with JWT
- apisearch-io/symfony-async-kernel — POC for a Symfony Async Kernel adapter.
- A PHP Compiler, aka The FFI Rabbit Hole — A very interesting read from Anthony Ferrara on compilers types, how they work, and on implementing an ahead-of-time (AOT) compiler for PHP using LLVM and PHP itself.
- PSR-14 Event Dispatcher was accepted a month ago, and Larry Garfield shared an awesome series of blog posts covering every aspect of the new standard.
- How we migrated 54,357 lines of code from Nette to Symfony with 2 people in under 80 hours.
- Running tests for PHPUnit from within PhpStorm
- azdanov/php-interview-exercises — A useful repo to practice solving classic algorithms. Good tasks to prepare for a job interview.
- On using ticks and stream wrappers to find segfaults in PHP like a boss.
- PHP-frameworks trends based on download stats, also comparing downloads by versions..
- Serverless PHP With Bref
🎥 Audio & Video
- 🎥 A stream on updating spatie/period — peeping at someone’s monitor could be quite educational.
- 🔈 Rant With Brent 01 – SOLID, interfaces, and final
Thanks for reading!
If you have any interesting links to share via PHP Annotated Monthly, please leave a comment or drop me a message on Twitter.
Your JetBrains PhpStorm Team
The Drive to Develop
Subscribe to Blog updates
Thanks, we've got you!