PHP Annotated – June 2024
Welcome to the June edition of PHP Annotated! We’ll recap the most interesting developments in the PHP community over the past couple of months, featuring handpicked news, articles, tools, and videos.
Highlights
PHP 8.1.29, PHP 8.2.20, and PHP 8.3.8 released
❗️These security updates fix CVE-2024-4577, CVE-2024-5458, CVE-2024-5585, and vulnerability in openssl_private_decrypt() function known as the Marvin attack.
Happy 29th birthday, PHP!
On June 8, PHP turned 29 years old! For a throwback, check out Rasmus Lerdorf’s initial public announcement of PHP.
I published a video where I compiled and ran the very first version of the language. Witness what PHP was like 29 years ago:
Here’s to many more years of empowering developers and pushing the boundaries of web technology. Happy Birthday, PHP! 🎉🥳🎂
PHP 8.4
The next version of the language is shaping up nicely, and the first Alpha has already been tagged. Here’s what’s coming:
Property Hooks
new without parentheses
New DOM HTML5 support
Many new functions: array_find(), array_find_key(), array_any(), array_all(), grapheme_str_split(), DateTime(Immutable)::get/setMicrosecond(), DateTime(Immutable)::createFromTimestamp(), mb_ucfirst(), mb_lcfirst(), mb_trim(), mb_ltrim(), mb_rtrim(), http_(get|clear)_last_response_headers(), request_parse_body().
And on top of that, there are many more cool tidbits. Here are a couple lesser-known ones:
PCRE2 Upgrade and Regular Expression Changes by PHP.Watch.
Engine optimization of sprintf() to string interpolation by Benjamin Eberlei.
How many PHP developers are there in the world?
SlashData, a company specializing in developer surveys, has published a report assessing the demand for programming languages and predicting the size of programming language communities.
According to the report, PHP ranks sixth with 9.8 million developers worldwide.
MySQL 9.0 is available
There aren’t many new features in it, but the new VECTOR column type is probably the most notable one.
PHP Core
✅ RFC: Add stream open functions to XML{Reader,Writer}
Thanks to Niels Dossche, PHP 8.4 will have two new methods to create instances of the respective classes from an already open stream: XMLReader::fromStream(), XMLWriter::toStream().
📣 RFC: Static Constructors
Erick de Azevedo Lima suggests adding a new __staticConstruct() method to initialize static properties of a class before creating an instance.
Erick demonstrates the current workarounds people use, including in Composer, and analyzes how other languages solve this problem. The suggested solution is inspired by C#.
📣 RFC: Static class
Paul Morris suggests adding a new type of class – static. A static class is declared with the static keyword, and all methods and properties of that class are automatically static.
📣 RFC: Lazy Objects
Arnaud Le Blanc and Nicolas Grekas propose adding lazy objects to PHP. These objects will be initialized and consume resources only when reading or modifying a property occurs.
While lazy objects won’t be used directly by most users, they are primarily intended for library and framework authors, allowing them to remove a lot of boilerplate code.
📣 RFC: Deprecations for PHP 8.4
Niels Dossche, Gina Peter Banyard, Máté Kocsis, Tim Düsterhus, Kamil Tekiela, and Jorg Sowa have launched an RFC discussion to determine which functionality should be deprecated in PHP 8.4 and removed in PHP 9.0.
Beware, it has a few controversial suggestions that might affect your projects. Such as deprecating uniqid(), md(), sha1(), md5_file(), and sha1_file() functions. So if you disagree with the proposed changes, make sure to voice out your concerns on the mailing list.
PhpStorm
Updates for security issue affecting IntelliJ-based IDEs 2023.1+ and JetBrains GitHub Plugin.
📺 PhpStorm for Laravel Developers – 3-Hour Full MasterClass by Jeffrey Way.
PhpStorm 2024.2 EAP Highlights – The upcoming release of PhpStorm will include support for viewing log files with highlighting and other perks.
Tools
FrankenPHP v1.2.0 – This update of the PHP application server comes with a built-in Caddy 2.8 web server, support for full-duplex HTTP/1 connections, and other features.
buggregator/server – Buggregator is the ultimate debugging tool that works as a VarDumper server, Xhprof profiler, local SMTP server, local Sentry, and much more.
Check out Pavel Buchnev’s post on Profiling PHP (Laravel)Applications with xhprof.
And for some inspo, see Buggregator for local WordPress development configs.
php-soap – A drop-in pure PHP replacement for the ext-soap extension.
davecheney/httpstat – A neat visualization tool for HTTP requests. #notphp
php-static-analysis/attributes – This package allows using Attributes instead of PHPDoc annotations for static analysis with PHPStan.
And if you’re new to attributes, check out this guide to PHP attributes by Ashley Allen.
rectorphp/type-perfect – Next level type declaration check PHPStan rules.
phpstan/phpstan-doctrine – Doctrine extensions for PHPStan.
If you’re hesitant to use it, check out this thread about possible problems with types returned from database:
🧵 #phpstan–#doctrine 1.4.4 just received major improvements 🚀
In #PHP, types returned from database:
– differ per platform
– differ per driver
– changes with PHP versions
– changes with driver setup
– functions alter those types
What a MESS! Lets continue…👇
— Jan Nedbal (@janedbal) July 1, 2024
koriym/spaceman – Give namespace to un-namespaced legacy PHP code.
olinox14/path-php – Object-oriented file and path operations, inspired by the path.py python library.
cognesy/instructor-php – Structured data outputs with LLMs, in PHP. Designed for simplicity, transparency, and control.
NumPower/numpower – A PHP extension for efficient scientific computing and array manipulation with GPU support.
Check this simple neural net build in PHP from scratch using NumPower.
krakjoe/parallel – A succinct parallel concurrency API for PHP. This extension has been updated recently and is now compatible with PHP 8.2 and 8.3.
Curious about use cases? Check out this example: Processing One Billion Rows in PHP.
Swoole v6.0.0-alpha – This alpha release showcases significant changes coming to Swoole, such as multi-threading mode, and support for io_uring for file operations.
Note: Always use the original Swoole and not Open Swoole! The latter is a scam version parasitizing on the original extension.
seanmorris/php-wasm – PHP in Browser, powered by WebAssembly. The maintainer is now supported by WordPress, so it has received quite a few interesting updates recently, such as loading extensions dynamically.
Version v0.0.9 also includes php-cgi-wasm, which executes the php-cgi SAPI and behaves more like the PHP that runs under Apache, and less like the PHP you invoke on the CLI. This allows you to run almost any PHP application completely client-side.
Symfony
zenstruck/foundry – A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.
2 Tricks to get your Symfony configs lines to minimum by Tomas Votruba.
Extend your Symfony Console app with events and attributes by Fernando Castillo.
Multi-tenant and Symfony by Cyril Pereira.
Symfony core member Oskar Stark shares nice pull request overviews on his X:
Symfony Pull Request Review🔎
Starting from @symfony 7.2, a new mailomat bridge has been added to the Mailer component, enhancing email handling capabilities by integrating with Mailomat’s remote events. This feature aims to provide a seamless experience for developers working… pic.twitter.com/XAmCYal4Py
— Oskar Stark (@OskarStark) July 3, 2024
Laravel
thedevdojo/auth – A plug’n’play authentication package for any Laravel applicaiton.
corcel/corcel – A collection of PHP classes built on top of Eloquent ORM to get data directly from a WordPress database.
kitloong/laravel-migrations-generator – Automatically generate your migrations from an existing database schema.
Using Models as Flags by Andreas Alsterholm.
The ultimate guide to Laravel Validation by Ashley Allen.
Use HTMX to Create Laravel Single-Page Apps Without Writing JavaScript by Nico Devs.
How to Contribute to Laravel: A Step-by-Step Guide by Mohammed Samgan Khan.
Other Frameworks
Dotkernel API: a replacement for legacy Laminas API Tools – We don’t hear much from Laminas Project (formerly Zend Framework) these days, but the team and community are active.
Dotkernel is an example of that – a collection of PSR-7 middleware applications based on Laminas and Mezzio microframework. And Dotkernel API () is one such application.
Misc
📺 Story of PHPUnit, PEST PHP, And More with Nuno Maduro and Sebastian Bergmann.
Use OpenAIs Assistant to Chat with Your whole Codebase by Micha(el) Bladowski.
Performance Metrics Using Guzzle by Paul Underwood.
Avoiding imports and aliases in PHP by Andreas Möller.
A Quickstart Tutorial on PHP Generators by Christian Olear.
The Difference Between self::, static::, and parent:: in PHP by Ashley Allen.
Success Story of Automated Framework Migration from FuelPHP to Laravel of 400k+lines Application by Tomas Votruba.
How Well Do You Really Understand PHP Generators? by Serghei Pogor.
Readable end-to-end tests for PHPStan with bashunit by Markus Staab.
Practical Logging for PHP Applications with OpenTelemetry by Marin Bezhanov.
WeakMaps a hidden gem in PHP by Flare Team.
How to leverage Temporal Workflows for efficient document lifecycle management by Anton Titov.
Algorithms in PHP: Deques (and circular buffers + linked lists) by Robert Landers.
Conferences
These PHP events are all worth a visit, and some are still accepting presentation proposals:
CakeFest – Luxembourg, July 24–26.
Laracon 2024 – Dallas, TX, USA, August 27–28.
PHP Serbia 2024 – Belgrade, Serbia, September 6-7. CFP
CascadiaPHP 2024 – Portland, OR, USA, October 24-26. 🆕
PHPCon Poland 2024 – Wisła, Poland, October 25–26. CFP
Laracon AU – Brisbane, Australia, November 7–8.
International PHP Conference – Munich, Germany, November 11‒15. 🆕
SymfonyCon 2024 – Vienna, Austria, December 5–6. CFP
Community
PHP has the nicest community!
If you have any interesting or useful links to share via PHP Annotated, please leave a comment on this post or let us know on X (formerly Twitter).
PhpStorm : The Lightning-Smart IDE for PHP Programming | The JetBrains Blog