PHP Annotated – September 2019
Greetings everyone,
It’s time for our September edition of PHP Annotated! Get the latest on PHP 7.4.0 RC 1, Laravel 6, Monolog 2, and other releases. There are loads of insights from PHP Internals, including Union Types RFC, plus we’ll share links for Laravel and Symfony, useful tools, videos, podcasts, and a whole lot more!
⚡️ News & Releases
- PHP 7.4.0 RC1 – The release-candidates cycle for the 7.4 branch has started now. At least 6 RCs are expected before the GA release.
- PHP 7.1.32, PHP 7.2.22, PHP 7.3.9 – Security releases with fixes for critical vulnerabilities. All users are encouraged to update.
- Monolog 2.0.0 – It’s been 4 years since it was first announced and now, finally, Monolog 2.0 is released. It requires PHP 7.2, uses type hints where possible and strict_types mode, and has new handlers (e.g. SqsHandler, TelegramBotHandler) and more. Support for Monolog 1.x will continue.
🐘 PHP Internals
- Straw poll for P++ feasibility – Just in case you missed it, the P++ idea was rejected unanimously by the PHP community as completely unfeasible.
- [PoC] throw_legacy_failure declare statement – An interesting pull request to PHP proof of concept for letting internal/old functions be able to throw an Exception in case of failure, instead of using the legacy behavior of returning
null
orfalse
. This behavior is controlled using the declare statement:declare(throw_legacy_failure=1)
. - [RFC] Reclassifying engine warnings – Nikita Popov proposes taking a look at the existing warnings and notices in the engine, and thinking about whether their current classification is still appropriate: “Undefined variable” should be at least a Warning.
- [RFC] Union Types v2 – Another epic proposal from Nikita continues on the work of Bob&Levi. It suggests adding union types in PHP 8. It would mean that any variable can be one of the specified types. You have been able to use union types in PHPDoc for a long time, but now they are will be checked.
The proposed syntaxT1|T2|...
could be used anywhere you can use type declarations now:class Number { private int|float $number; public function setNumber(int|float $number): void { $this->number = $number; } public function getNumber(): int|float { return $this->number; } }
Noteworthy, the RFC is published as a pull request to php/php-rfcs repo and anyone can comment or react with emojis. The final vote will still take place at wiki.php.net as before. According to Nikita’s message, this first experiment went well despite some noise in top-level comments, and the proposal received a lot of valuable feedback from the community.
- In PHP 8 error_reporting will be
E_ALL
by default instead of the current:
E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
.
🛠 Tools
- RubixML/RubixML – An actively developed package for using machine learning in PHP. It has nice examples available: classifying human activities based on mobile phone sensor data, recognition of objects on images, and predicting house prices.
- Nyholm/psr7 – A lightweight and strict PSR-7 implementation.
- ivopetkov/html5-dom-document-php – Improved HTML5 parser. It extends and fixes the original DOMDocument.
- quasilyte/phpgrep – A tool for searching through PHP code – like grep, but with an “understanding” of PHP syntax. It is implemented in Go and is inspired by mvdan/gogrep. Similar to Structural Search and Replace (SSR) in PhpStorm.
- voku/portable-utf8 – A portable UTF-8 library to manipulate Unicode strings. Has zero dependencies and can work without mbstring or iconv extensions.
- PHPCompatibility/PHPCompatibility 9.3.0 – A set of rules for PHP_CodeSniffer to check compatibility with various PHP versions. Checks for PHP 7.4 were added.
- nunomaduro/yorn – A PoC for modules in PHP with JavaScript-like ‘import’ and ‘export’ syntax. The idea is not new at all, but the implementation is quite interesting.
Symfony
- Sylius 1.6 – A popular e-commerce platform based on Symfony. In this release, it has a refreshed admin area, and a headless mode.
- Abstracting API calls with Symfony serializer.
- Creating a dockerised Symfony application and a Makefile based build script.
- Validate an object based on its previous version.
Laravel
- Laravel 6 – A major framework update was announced at the Laracon EU conference. This is an LTS release and will get security updates for 3 years. Also, the framework follows Semver for release versions. It means that we will be seeing more first number increases, and version 7 will be released this coming winter. See what’s new in Laravel 6 at Laracasts.
- facade/ignition – Among other things, Laravel 6 has a brand new error page. It is based on Whoops, but it provides more information and even allows you to fix some issues without ever leaving your browser.
- Videos from Laracon US 2019
- PHP Townhall #68: Behind the Facade – Matt Trask and Ben Edmunds are joined by Taylor Otwell to discuss what’s new with Laravel, the business side of things, and what it’s like organizing a huge conference.
🌀 Async PHP
- Creating a RESTful API with ReactPHP: Improving HTTP responses, Managing Orders
- apisearch-io/symfony-async-kernel – Async kernel for Symfony based on ReactPHP promises. See the demo application: apisearch-io/symfony-react-demo.
- clue/reactphp-stdio – Аn async tool for creating really interactive CLI-tools with ReactPHP. See the intro post.
💡 Misc
- How to use data providers in PHPUnit.
- From LAMP to serverless: a case study on externals.io migration.
- A first look at Slim 4.
- Analysis of SQLi and PHP Object Injection vulnerabilities in SuiteCRM.
- Being explicit about entity managers.
- Videos from the Blackfire meetup at Datadog NYC HQ – Profiling PHP apps with Blackfire, Tracing: Flame graphs of your production PHP, and Developing cacheable backend applications.
🔈 Podcasts
- PHP Internals News #24, PHP Internals News #25 – With Stanislav Malyshev on security related aspects of PHP development and using a fuzzer to test the input safety of data coming into PHP.
- PHP Internals News #26 – With Nicolas Grekas about how the Symfony project approaches the task of making it ready for PHP 7.4.
- php[architect] – Symfony 4, legacy code, the future of PHP, and Karl Hughes.
- No Plans to Merge – @DCoulbourne and @calebporzio talk about Laravel 6 and other things.
💬 Community
- Matthew Weier O’Phinney is looking for new adventure – Lead of Zend Framework (Laminas) and a founding member of PHP-FIG, has finished his work at Zend.
- Brent Roose and Joe Watkins exchanged opinions on where the PHP team is right now, and what can be done to make it better: A letter to the PHP team – Re: Bearings – Re: Re: Reply to Joe.
- One interesting thought from Joe:
The most important thing missing from the #PHP ecosystem at the moment is not generics or typed variables – it's funding. Funding projects like @Xdebug, @PHPUnit and #composer, so that they can *always* afford to provide for free what they provide today, is extremely important.
– Joe Watkins (@krakjoe) August 30, 2019
So if you’re using PHP, consider giving back to the community and supporting the authors of the tools you use. Here are some funding pages you may find interesting:
• Sebastian Bergmann – PHPUnit
• Derick Rethans – Xdebug
• Vladimir Reznichenko – Php Inspections
• WyriHaximus – ReactPHP
• Tomas Votruba – Rector
• Matthew Weier O’Phinney – Zend Framework (Laminas)
• Yii Framework
• Doctrine
Thanks for reading!
If you have any interesting or useful links to share via PHP Annotated, leave a comment or drop me a message on Twitter.
Your JetBrains PhpStorm Team
The Drive to Develop