PHP Annotated Monthly – February 2019
Please welcome February edition PHP Annotated Monthly, with all the latest news and notable materials coming from the world of PHP. Read all about the PHP 8 development that’s underway, JIT in PHP, PSR-14 and PSR-12 in review, a bunch of new RFCs from PHP Internals, Laravel, Yii, Symfony, async PHP stuff, useful tools, and a whole lot more!
⚡️ News & Releases
- PSR-14 Event Dispatcher — is officially in the review stage.
- PSR-12 Extended Code Style — The new code style standard to replace PSR-2 is also in the review stage now. Read more about PHP-FIG news in the latest recap.
- PHP 7.3.2
- PHP 7.2.15
- PhpStorm 2019.1 EAP — Another reminder that we’ve started an Early Access Program for the next PhpStorm version. Join it and be one of the first to preview the newest features, including support for debugging Twig templates, multiple new intentions for juggling strings, improved autocompletion for function arguments, code cleanup for PHP, and container lifecycle management for Docker Compose, to name just a few.
- PHPUnit Version 8
- PEAR was hacked
🐘 PHP Internals
- PHP-7.4 has been branched, and the master now targets PHP 8.0. Branching usually meant a feature freeze for the version, but this time it was done so that both PHP 8 and PHP 7.4 could be developed in parallel. Lots of deprecated stuff is already removed from PHP 8.
You may try both PHP 8 and PHP 7.4 using Docker images phpdaily/php.
- [RFC] JIT — Finally proposed by Dmitry Stogov. JIT is implemented as an almost independent part of OPcache and may be enabled/disabled at PHP compile time and at run-time. The target is PHP 8, but there is an ongoing discussion about whether to include it in PHP 7.4 as an experimental feature. As benchmarked by Nikita Popov, JIT gives a 30% boost for PHP-Parser and ~5% for amphp/http-server. There are some concerns about Windows support.
You may try PHP+JIT with this Docker image. Check out also a nice write up on what is JIT for PHP.
- [RFC] RFC Workflow & Voting (2019 update) — There were some rants about the proposed changes to RFC process, and even an alternative proposal raised. Zeev Suraski promised to work on it and take the feedback into account.
- [RFC] Weak References — It is proposed to add a
WeakReferenceclass, that will allow keeping a reference to an object without preventing it for being deleted with garbage collector. For example, this could be useful for implementing caches.
- [RFC] Null Coalescing Assignment Operator — The RFC was accepted more than 2 years ago, and now Nikita has delivered an implementation for the new operator
??=. While it seemed like a simple task, it turned out anything but.
$a ??= $bis equivalent to
$a ?? ($a = $b). In case
$a[foo()] ??= bar()then
foo()function will be called exactly once, and
bar()will be called, if
Read more about shorthand comparisons in PHP.
- [RFC] New custom object serialization mechanism — In this one, Nikita proposes a new serialization mechanism for objects by introducing a couple of magic methods:
- [RFC] Consistent type errors for internal functions — Another proposal by Nikita Popov to make internal functions always throw TypeError (in PHP 8) when parameters with incorrect types are passed, instead of warning and returning null. Removes an internal/user-defined inconsistency, and unblocks specifying param types for Reflection.
- [RFC] Allow void return type variance — A proposal to allow overriding
voidreturn type of a method in a subclass.
- [RFC] Mixed typehint — Here it is proposed to add a
mixedtypehint. This would allow explicitly specifing that a function may accept or return values of different types.
- [RFC] Annotations 2.0 — A draft proposal for annotations. There have been attempts before to add annotations via attributes and simple annotations. For now, you can use annotations and get full support for them in PhpStorm with the php-annotations plugin.
- mnapoli/bref v0.3 — A tool for making serverless PHP apps on AWS Lambda. In the latest version, the Nodejs hack is removed and custom runtime feature is used instead. You may also use img2lambda as an alternative.
- leocavalcante/siler — A microframework based on plain functions and no classes. May be used with Swoole
- mgp25/Instagram-API — The package allows using Instagram features that are not available in the official API.
- bmitch/churn-php — The tool will help will find candidates for refactoring – files that have been modified most according to the Git log and those with the greatest cyclomatic complexity.
- paragonie/ciphersweet — Fast, searchable field-level encryption for PHP projects. More details in the blog post.
- akondas/php-grandmaster — A chess engine, written in PHP and deployed to AWS Lambda.
- krakjoe/pcov — Fast code coverage driver delivered as an extension. More in the blog post.
- krakjoe/sandbox — This extension allows running a closure in a sandbox environment. Read more in the blog post.
- spatie/enum — Strongly typed enums in PHP supporting autocompletion and refactoring
- railt/railt — An interesting (but WIP) PHP GraphQL Framework.
- 🎥 The SymfonyCon 2018 videos — Including Fabien’s keynote on dev server.
- A week of Symfony #632 (4-10 February 2019)
- 2 Files that Your Symfony Application Misses: ide-twig.json, .phpstorm.meta.php.
- Testing Symfony applications with PhpStorm
- Ask me anything with Fabien Potencier
- brendt/aggregate.stitcher.io — A nice example of a Laravel application. Community-driven content aggregator – aggregate.stitcher.io.
- beyondcode/laravel-favicon — Create dynamic favicons based on your environment settings.
- beyondcode/laravel-mailbox — A Package for handling incoming emails in Laravel applications.
- spatie/laravel-eventsauce — Event sourcing for Laravel applications; based on EventSauce.
- 11 Awesome Laravel Helper Functions (that aren’t avilable in Laravel)
- 🎥 Videos from Laracon EU 2018
- 🔈 Taylor Otwell’s Laravel Snippet podcast
- Yii 2.0.16 is released
- Yii development notes #26
- iiifx-production/yii2-autocomplete-helper — Autocompletion in your IDE for custom components in Yii 2.
🌀 Async PHP
- reactphp/event-loop v1.1.0 — Finally with libuv (ext-uv) event loop, async PCNTL signal handling, and high resolutions timers on PHP 7.3+
- dantleech/fink — A tool for checking a website for broken links. Implemented using amphp/artax.
- shuchkin/react-smtp-client — Async SMTP Client to send a simple email on ReactPHP.
- 🎥 Fast Web Scraping With ReactPHP #3: Downloading Images
- A classic post on when to declare classes final, and a fresh addition to it.
- Uncovering PHP bugs with @template — The post discusses generics functionality available in PHP static analysis tools vimeo/psalm, and phan.
- Context Managers in PHP — An interesting idea to implement an analog to Python’s context manager with generators in PHP.
- Moving from Go to PHP again
- 🎥 Beachcasts Tech Videos — Streams and video tutorials by Adam Culp.
- 🎥 Astrocasts — Another source of cool streams about PHP, this time by Beau Simensen.
Thanks for reading!
If you have any interesting or useful links to share via PHP Annotated Monthly, leave a comment or drop me a message on Twitter.
Your JetBrains PhpStorm Team
The Drive to Develop