PHP Annotated – October 2022
Greetings everyone!
Welcome to the October installment of PHP Annotated, where we’ll catch up on the most exciting things that have happened in the PHP world over the last month, including curated news, articles, tools, and videos.
News
- PHP 8.2.0 RC 5 has been released
Another release candidate has been delivered according to schedule. The sixth RC is expected on November 10, and it’ll be the last one before the final release of PHP 8.2.For a detailed list of what’s coming in PHP 8.2, take a look at PHP.Watch or stitcher.io.
You may also want to check out PHP 8.2 in 8 code blocks.
Me: “Hey Joe! What do you think about modern PHP?”
Joe: pic.twitter.com/r3Qh5vCr6h
— Martin Joo (@mmartin_joo) September 29, 2022
- PHP 8.0.25 and PHP 8.1.12 have been released
❗These are security releases of currently supported branches. All users are encouraged to upgrade.
The updates fix vulnerabilities in Phar extension and cookie integrity. You can learn more in this blog post on PHP.Watch.
- AWS X-Ray launches support for tracing PHP applications via OpenTelemetry in public preview.
- The RedMonk Programming Language Rankings: June 2022
And RedMonk NEVER discusses it. They only talk about the languages hashing it out in the top 3, or when other “popular” languages rise or fall lower down the list.
It’s part of how #php is relegated to “dead” or “uninteresting”.#tw
— mwop (@mwop) October 24, 2022
PHP Core
Most of the Core news is covered in detail in the PHP Core Roundup series from the PHP Foundation, so we’ll only mention it briefly:
- ✅ RFC: json_validate #PHP 8.3
Juan Carlos Morales proposed adding a new function calledjson_validate()
that verifies whether a string contains a valid JSON. It saves memory when you don’t need to fully parse the string, but rather just check if it’s a JSON.var_dump(json_validate('{ "test": { "foo": "bar" } }')); // bool(true) var_dump(json_validate('{ "": "": "" } }')); // bool(false)
- ❌✅ RFC: Improve
unserialize()
error handling #PHP 8.3
Tim Düsterhus proposed throwing a newUnserializationFailedException
when unserialization fails.This RFC caused a massive discussion on Twitter, and ultimately the new exception part was not accepted. Instead, the severity of the thrown error will now be increased from
E_NOTICE
toE_WARNING
. - 📣 RFC: Randomizer Additions #PHP 8.3
Tim Düsterhus and Joshua Rüsweg propose adding new “building block” methods to\Random\Randomizer.
These methods would implement commonly useful operations that are either verbose or very hard to implement in user land.namespace Random; final class Randomizer { // […] public function getBytesFromAlphabet(string $alphabet, int $length): string {} public function nextFloat(): float {} public function getFloat(float $min, float $max): float {} }
- 📣 RFC: Destructuring Coalesce #PHP 8.3
Bob Weinand proposes adding an operator for default values in destructuring assignments.$input = 'key=value'; [$key, $val ?? 'default value'] = explode('=', $input, 2);
By the way, the defaults can now be appended to the array like so:
[$key, $val] = explode('=', $input, 2) + [null, null]
Thanks for the tip, Sergii Shymko!
-
This was supposed to be a secret, but it got documented …
The #PHP CLI server can handle multiple requests concurrently if you set PHP_CLI_SERVER_WORKERS since 7.4 …
This has been various kinds of broken, but might be alright in the latest versions of PHP *for development*.
— Joe Watkins (@krakjoe) October 26, 2022
Tools
- dunglas/frankenphp – The modern PHP app server, written in Go and embedded in Caddy web server.
Kevin Dunglas summarized this server’s main differences from RoadRunner: - krakjoe/parallel – A succinct parallel concurrency API for PHP 8+. The extension follows Golang’s philosophy on parallelism – “Do not communicate by sharing memory; instead, share memory by communicating” – and provides all the necessary bricks, like Channels, Events, and Futures.
- cachewerk/relay – A Redis client like PhpRedis and Predis, but much faster because it is written as a PHP extension. The authors also provide Laravel, WordPress, and Magento integrations for caching.
- Saeghe – A modern PHP package manager.
PHP now has one more package manager! It uses GitHub links as dependencies. Additionally, it does not rely on PSR-autoloading, relying instead on a build stage.Competition is always a good thing!
- composer-unused/composer-unused – A package that scans your code to reveal unused composer dependencies.
- square/pjson – This library helps deserialize JSON into actual objects of custom-defined classes. It does so by using PHP 8’s attributes on class properties.
- doctrine/collections 2.0.0 – A popular collections library that has received a major update adding more strict typing and native parameter and return types.
- heiglandreas/holidayChecker – This package allows checking whether a given date is a holiday and is locale-aware.
- Laragon – Another local dev environment tool – one that’s a portable, isolated, fast, and powerful alternative to XAMPP and similar solutions. Learn more in this post on PHP.Watch.
- gacela-project/gacela – This package helps you build modular PHP applications, by splitting your project into different modules in a unified way. Heavily inspired by Spryker.
Symfony
- Symfony: translate Assert custom messages from entities by Thomas Dutrion.
- ❗️ Twig security release: Possibility to load a template outside a configured directory when using the filesystem loader by Fabien Potencier.
- CQRS Principle with Symfony Messenger by Mert Simsek.
- emr-dev/sf-bug-bundle – A package for sharing Symfony profiler pages. Here’s how it works.
- Emojis are new Symfony’s best friends! by Alexandre Daubois.
- New in Symfony 6.2: Built-in Cache, Security, Template and Doctrine Attributes by Javier Eguiluz.
Laravel
- What’s new in Laravel 10? by Benjamin Crozat – Laravel 10 will be released on February 7, 2023. Its development is still ongoing.
- spatie/laravel-dynamic-servers – A package for dynamically creating and destroying servers. Here’s how to use it.
- ryangjchandler/laravel-feature-flags – An opinionated feature flags package for Laravel. Learn how to use it to add feature flags to your Laravel project.
- creagia/laravel-sign-pad – A package for signing documents and optionally generating certified PDFs associated with Eloquent models. Here’s how to use it.
- hammerstonedev/sidecar – A tool to deploy and execute AWS Lambda functions from your Laravel application.
- Using jobs instead of commands in the schedule of a Laravel app by Freek Van der Herten.
- Laravel’s safety mechanisms by Aaron Francis.
- 📺 Laravel Bootcamp: from start to finish by Brent Roose.
- 📺 What’s new in Laravel 9.32.0 by Christoph Rumpel.
- 📺 Laravel’s New Strict Mode (Everything You Need to Know) by Jeffrey Way.
Misc
- Why I Don’t Enjoy Writing PHP Anymore by Michael Bodnarchuk – Despite its click-baity title, this post raises a constructive concern regarding backward compatibility breaks in PHP versions.
One of the Composer’s authors, Jordi, posted a tip that might help work around some of the upgrade problems:
Also, please for safety use –ignore-platform-req=php+
With the plus sign it allows using php 8.2 where 8.1 is required by a pkg, but not using php 8.0 if 8.1 is required.
— Jordi Boggiano (@seldaek) October 4, 2022
- All the Easter Eggs in PHP by Ayesh Karunaratne.
- Pragmatic development 3: Telegram bot by Vladimir Martsul.
- Loosely coupled Microservices in PHP by Dariusz Gafka.
- Unpacked, named and positional arguments are in a call… by Damien Seguy.
- Extrinsic sorting: A benchmark by Larry Garfield – In which he explains priority, group, topological, and other non-trivial sortings.
- Contract Tests by Kai Sassnowski – Guidance for writing tests to ensure consistent behavior across all implementations of an interface.
- PHP preload VS running as a daemon (RoadRunner) – Benchmarks by Pavel Murzakov.
- Supporting Legacy PHP project: painless switching to cloud storage by Vlad Reshetilo – A neat trick for using PHP’s native stream API.
- How to build your next PHP project with a touch of AI by Benjamin Crozat.
- Modern PHP features explained – PHP 8.0 and 8.1 by Steve McDougall.
- Using PHP enums as method calls by Thorsten Suckow-Homberg – Dynamically mapping method calls to existing typed values – what a neat and unexpected usage of enums.
Videos
- 📺 My Top 10 PhpStorm Tricks by Christoph Rumpel.
- 📺 Tiny Refactors Make a Big Difference by Jeffrey Way.
- 📺 PHP For Beginners by Jeffrey Way.
- 📺 What’s Changed in PHP 8.2 by Scott Keck-Warren.
Conferences
Check out these upcoming big PHP gigs, and consider visiting or submitting a talk idea:
- SymfonyCon – Disneyland Paris (France), November 17–18, 2022.
- PHP UK Conference – London (UK), February 14–16, 2023.
- Laracon EU – Lisbon (Portugal), January 2023.
- Php[tek] – Chicago (US), May 16–18, 2023.
And if you are wondering when the next PHP meetup is, Tomas Votruba has got you covered with his lovely friendsofphp.org meetup aggregator. There is also a calendar on php.net – Events: November 2022.
That’s all for today, thanks for reading!
If you have any interesting or useful links to share via PHP Annotated, please leave a comment on this post or send
me a tweet.
Your JetBrains PhpStorm team
The Drive to Develop