PHP Annotated – August 2019
In our August edition of PHP Annotated, read about the future of PHP. Is it P++ or PHP2020? Get the latest on PHP 7.4.0 beta 2, Slim 4, and other releases. We cover Laracon US, as well as share other links for Laravel and Symfony, useful tools, videos, and a whole lot more!
⚡️ News & Releases
- PSR-12 Extended Coding Style Guide is accepted and is now the official standard. See the changelog from PSR-2.
- PHP 7.4.0 beta 2 – The active development phase is over, and we can consider the list of new features final. For extensions developers, there’s a list of internal API changes.
- PHP 7.3.8, 7.2.21, 7.1.31
- Slim 4.0.0
- Composer 1.9.0
🐘 PHP Internals
- P++ – The controversy and accusations in PHP Internals over the removal of short tags
<?, explicit call-site send-by-ref syntax, and other discussions eventually resulted in an unexpected proposal from Zeev Suraski – create a new PHP dialect. The working name P++ is not accidental here, as Zeev suggests creating a “sister” language, like C++ for C. PHP and P++ are supposed to be developed side by side within a single runtime.
In the new P++ it will be possible to implement a lot of revolutionary improvements, to deprecate legacy, and clear things up without thinking about backward compatibility. Since the language would have new branding, it would not have this bad reputation. A “classic” PHP would get all the performance and other non-syntax features but maintain backward compatibility.
The proposal received a lot of counterarguments, which Zeev tried to address on a page P++ idea: FAQ. The questions are quite serious though: limited team (just ~2 people working on PHP fulltime), possible community fragmentation, Hack’s experience, how PHP and P+++ code would really coexist and interact, and a lot more.
- [RFC] Namespace-scoped declares, again – In the scope of this RFC, Nikita Popov formulates a more evolutionary approach to language development. In a nutshell, using optional directives like
strict_types, for example.
There are two possible ways of implementation: fine-grained – where individual changes are controlled by separate declare directives, and coarse-grained – when a bunch of features are combined into one directive as part of an “edition” such as “PHP 2020” for example. Similar to Editions in Rust.
- Call for participation: Annotating internal function argument and return types – Ever wanted to become a PHP core contributor? You couldn’t think of a better time to start!
Lack of type information for internal functions in Reflection is a long-standing issue. In PHP 8, all the necessary technical groundwork to support argument and return type annotations on internal functions at scale is already done. The only thing left is to add those type annotations to functions. This is something everyone can help with as it does not need expertise in C. Nikita has opened a sample PR to show the process: https://github.com/php/php-src/pull/4499.
- krakjoe/tombs – A tool for locating dead code. You plug this in on production without the fear of performance overhead or any code modifications, wait for a day/week/month, and then look at the statistics to see which functions/methods have never been executed. Read more in Joe Watkins’ blog post.
- krakjoe/stat – One more cool tool from Joe. This is an extension for profiling PHP applications in production which gives profiling info in a parallel thread. For more details, see this blog post.
- nunomaduro/pest – A nice syntax sugar for PHPUnit that allows writing tests in facebook/jest style.
- mpratt/Embera – An Oembed consumer library which gives you information about URLs. It helps you replace URLs to YouTube or Vimeo, for example, with their HTML embed code.
- NxtLvLSoftware/php-static-constructors – Static constructors à la C#. They are executed automatically and not more than once.
- exussum12/coverageChecker – The instrument helps you introduce good practices into your project gradually. For example, you can require 90% code coverage with tests, and not for the whole codebase at once, but just for the changed piece.
- DaveLiddament/sarb – A similar tool that implements a Baseline feature for the quality analysis tools, which allows you to use them in legacy applications.
- SymfonyCloud – The service for Symfony applications deployment has come out of beta and is now available to everyone. It allows you to describe the infrastructure in yaml configs and then deploy, update, take snapshots, etc. with one command. See an example of how it was used for redirection.io.
- Minor non-LTS releases of Symfony will be supported for 8 months instead of 14.
- A week of Symfony #658 (5-11 August 2019).
- Decouple your Symfony application using Domain Events.
- 🎥 Taylor’s talk at Laracon US:
• Laravel 6 will be released in August.
• The framework will move to Semver (components already follow it).
• New branding:
• Laravel Vapor announced – A paid service for deploying Laravel applications in an AWS infrastructure: Lambda, RDS, CloudFront, S3, and CloudWatch. It comes with a hosted web interface and a CLI tool for configuring, deploying, and monitoring applications. Neat!
- What is AWS Lambda and how Laravel Vapor uses it.
- 🎥 Simplification Tips and Tricks (Laracon 2019)
- calebporzio/livewire – This frontend framework for Laravel lets you write bindings in Blade directly to PHP classes without having to write any additional JS code.
- ylsideas/feature-flags – A Laravel package for handling feature flags.
- Lowering the time cost of testing existing Laravel applications.
- Service locator: an anti-pattern.
🌀 Async PHP
- Deploying Laravel Artisan on AWS Lambda with bref.
- Another case study for using AWS Lambda and bref.
- Serverless PHP on App Engine + Cloud Firestore and Firevel.
- Dividing responsibilities – A chapter from a new book by Mathias Noback.
- How to write cloud-native and container-ready PHP applications.
- How to create a PhpStorm plugin that adds more code generation capabilities.
- How we completed thousands of missing @var annotations in a day.
- Accessing private properties without Reflection – a nice variation of an old trick:
Read private properties in PHP without reflection
— Rasmus Schultz (@mindplaydk) August 7, 2019
- 🔈 PHP Internals News #20 – With Nikita Popov about improvements to test PHP on many more platforms and in many more configurations.
- 🔈 PHP Internals News #21 – With Will Hudgins about his “Add str_starts_with(), str_ends_with() and related functions” RFC.
- 🔈 PHP Internals News #22 – With Matteo Beccati about his RFC “Escape PDO “?” parameter placeholder”.
- 🔈 That Podcast Episode 63 – With Benjamin Eberlei about Tideways.
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