PHP Annotated – September 2024

Welcome to the September edition of PHP Annotated! After a brief summer break, we’re back with all things PHP. This recap is carefully handcrafted and brings you the most interesting developments in the PHP community over the past couple of months, so you don’t have to sift through the noise—we’ve done it for you.

Highlights

Laravel raises a $57 million Series A from Accel

Right after the Laracon US, Taylor Otwell posted a tweet announcing a $57M investment from Accel, a renowned venture capital firm.

Congratulations to Taylor and the team!

Check out this video interview to learn more:

PHP 8.4.0 Beta 4 is available for testing

Updates for PHP 8.4 are released every two weeks, following the timeline. The final release is expected on November 21.

The feature freeze took effect on August 13, meaning the set of new features is now locked in, and any major changes will be postponed to the next PHP version.

Some of the most notable changes in PHP 8.4 include:

Property hooks
Asymmetric Visibility
new MyClass()->method() without parentheses
Lazy Objects
New HTML5 Support
New functions for working with arrays: array_find(), array_find_key(), array_any(), and array_all().

For a detailed list of what’s coming in PHP 8.4 see php.watch, stitcher.io, or Ash Allen posts.

Try PHP 8.4:

On Mac, you can install it using Homebrew through the Nightly channel via shivammathur/homebrew-php.
For other platforms, Docker images are probably the easiest way to try it out with no hassle.
For a quick local test, PHP 8.4 is also available on Herd.

State of Generics and Collections 💜

Arnaud Le Blanc, Derick Rethans, and Larry Garfield have published a comprehensive research article on the current state of generics in PHP. The article covers all possible implementations with the pros and cons of each.

You can join the ongoing discussion on the mailing list and Reddit.

In the meantime, you can start leveraging of generics with PHPDoc blocks.

Shutting down Packagist.org support for Composer 1.x

With over 95% of Composer updates now using v2, Composer v1 will be officially shut down on August 1, 2025.

PhpStorm 2024.2 is out

Highlights include:

Log files support
Completion in the new terminal
Editing from a floating toolbar
PER Coding Style
New UI Becomes the Default

Fundraiser by Joe Watkins : A big ask from a big community

Joe Watkins (@krakjoe), a pillar of the PHP community, needs help. Joe is one of the creators of The PHP Foundation and author of several PHP tools you’ve likely used in your work, including pcov, phpthreads, and parallel.

After battling severe health issues, he’s facing homelessness & loss of life-saving meds. Please donate if you can and help reshare ❤️‍🩹

„PHP is beautiful and powerful“

PHP Core

RFC: Asymmetric Visibility v2 💜

Thanks to Ilija Tovilo’s and Larry Garfield’s proposal, PHP 8.4 will have asymmetric visibility, i.e. possibility to make properties public for reading (get) and private for changing (set). The syntax was inspired by Swift.

RFC: Lazy Objects 💜

Lazy objects are standard objects except that their initialization is deferred until one of their properties is accessed (including non-existing ones). This can be useful
Arnaud Le Blanc and Nicolas Grekas successfully implemented this addition to PHP 8.4.

Very likely, the lazy objects won’t be used directly by most PHP users, but package and framework authors will benefit from it a lot as it allows them to remove a lot of boilerplate code. Here is for example how symfony/var-exporter will be simplified:

RFC: Transform exit() from a language construct into a standard function 💜

Gina Peter Banyard proposed to make exit() a proper function with the following signature: function exit(string|int $status = 0): never {}

The benefit is that it will properly validate the arguments passed and throw a TypeError if you pass something irrelevant, such as an array or resource.

📣 RFC: Improve language coherence for the behaviour of offsets and containers 💜

PHP supports offset accesses using brackets [] with the following notation $container[$offset]. However, the behavior of such accesses depends not only on the container type and offset, but also on the operation that is performed when accessing the offset. The existing behavior is highly inconsistent and difficult to predict.

Gina Peter Banyard proposes to improve language consistency for offsets and containers.

📣 RFC: Function Autoloading v4

Robert Landers proposes to add the ability to autoload functions by adding a 4th parameter to spl_autoload_register(…). Then with a simple PSR-4-like autoloader for functions, the code example could look like this:

spl_autoload_register(function ($function_name) {…}, false, false, SPL_AUTOLOAD_FUNCTION);

There is an alternative more comprehensive proposal from Gina P. Banyard: RFC: New core autoloading mechanism with support for function autoloading.

📣 RFC: Default expression

Paul Morris proposes to introduce the default expression in argument-passing contexts to use the default value of the function or method.

function greetingEveryone($greeting = ‚Hello‘, $subject = ‚World‘) {
return sprintf(‚%s, %s!‘, $greeting, $subject);
}

echo greetingEveryone(default, ‘Earth’)); // Hello, Earth!

A similar proposal has been declined in the past, and it seems the problem has already been solved with the named arguments

Tools

arokettu/composer-license-manager – The plugin for Composer that allows specifying license policies, e.g. list of allowed licenses for a project and avoid proprietary packages, packages with non-permissive licenses such as GPL, or no license at all. 🔗

php-tui/php-tui – A framework for creating console applications in PHP with pseudo graphical UI. terminal user interfaces (TUIs)

TomasVotruba/unused-public – It’s easy to find unused private class elements, because they’re not used in the class itself. But for public methods/properties/constants it’s not that straightforward.

composer/pcre – PCRE wrapping library that offers type-safe preg_* replacements.

clementtalleu/php-redis-om – A PHP object mapper for Redis. Check out the intro article for more details.

Sammyjo20/ssh-php – The ridiculously simple starting point for building PHP SSH apps.

ServBay – A local dev environment, alternative to Laravel Herd.

HiEventsDev/Hi.Events – Open-source event management and ticket selling platform.

freescout-help-desk/freescout – Free self-hosted help desk & shared mailbox (Zendesk / Help Scout alternative).

savinmikhail/Comments-Density – Analyze the comment density and quality in PHP files to maintain and improve code documentation quality.

prasathmani/tinyfilemanager – Single-file PHP file manager, browser and manage your files efficiently and easily with tinyfilemanager.

TicketSwap/phpstan-error-formatter – A minimalistic error formatter for PHPStan.

AI

TransformersPHP

It’s a PHP package that lets you run pretrained models from HuggingFace directly in PHP – no API, no extra server required.

The package is designed to be functionally equivalent to the popular Python Transformers library. So it’s easy to start using if you’re familiar with ML.

Here are some use-cases:

Building a Background Removal Tool with Laravel and TransformersPHP.
How to translate content programmatically using AI and TransformersPHP.
How to auto-generate the image Alt-Text using AI and Transformers PHP.
Machine Learning with PHP.

Under the hood, it uses ONNX Runtime and Math libray Rindow via FFI. And the cool part is that it handles everything for you, even downloading all the libs according to your OS with a small Composer plugin: CodeWithKyrian/transformers-libsloader.

llm-agents-php/agents – LLM Agents abstraction.

This package is a framework for creating, managing, and deploying AI agents within PHP environments. The library aims to simplify using Retrieval-Augmented Generation (RAG) techniques into PHP projects.

Check out a sample-app and a video showcase: Building a Blog with LLM Agents.

Symfony

Functional Tests with Symfony and Webhook component by Pierre Emmanuel Capel.
Bundling Your Symfony UX Twig Components by Yonel Ceruto.
zenstruck/console-extra – A modular set of features to reduce configuration boilerplate for your Symfony commands.
Symfony 7.1 curated new features

Laravel

Laracon US 2024

Last week, the flagship Laravel conference happened in Dallas, TX. Some big announcements were made, including:

Laravel Cloud
Pest 3
Invertia.js v2
Laravel VS Code extension
A few cool features for Laravel 11

The State of Laravel Survey 2024

The results of the annual survey are now published and have some interesting insights.

Check Brent’s overview of the results on YouTube.

Built with Laravel – Nice inspo catalog.
Laravel Config Problem: Is It Time for a Revolution?.
Learn to master Query Scopes in Laravel by Ashley Allen.
How to test all routes in your Laravel app by writing just a single Pest test by Freek Van der Herten.
Adding real-time chat in 14 lines of code with Laravel Reverb and Livewire by Simon Hamp.
Building Desktop Applications using Native PHP with Simon Hamp by Laravel News.

I challenged myself to run Laravel with rryqszq4/ngx-php, and ended up benchmarking other runtimes along the way:

Other Frameworks

Phalcon + Swoole in High Load Micro Service – A case study on using Swoole to turn PHP into a high-performance powerhouse!
Using Laminas Continuous Integration by Julian Somesan.
Current Maintenance Status of Laminas & Mezzio Packages by Julian Somesan.

Misc

Slowly introducing static analysis without changing everything by Joel Clermont.
Array Shapes For Preg Match Matches by Markus Staab.
Container Efficiency in Modular Monoliths: Symfony vs. Laravel by Kamil Ruczyński.
To double quote or not, that’s the question! by Florian Engelhardt.
Scope and Downgrade your PHP Tools for Everyone to Use by Tomas Votruba.
The #[Override] Attribute in PHP by Ashley Allen.
Store Code Discussions in Git using Git Notes by Wouter de Jong – This is how Symfony stores GitHub Discussions in Git.
Choosing a PHP Library based on Performance by Benjamin Eberlei.
How to use PHP-VCR to record and replay API calls in PHP – by Imen Ezzine.
Inheritance in modern programming languages is different… by Brent.
How to build a game engine in a CMS, in PHP by Jack Wilkinson.
How Craft CMS built Craft Cloud – A case study from Bref, the serverless PHP tool.

Conferences

These PHP events are all worth a visit, and some are still accepting presentation proposals:

CascadiaPHP 2024 – Portland, OR, USA, October 24-26.
PHPCon Poland 2024 – Wisła, Poland, October 25–26.
Laracon AU – Brisbane, Australia, November 7–8.
International PHP Conference – Munich, Germany, November 11‒15.
SymfonyCon 2024 – Vienna, Austria, December 5–6.
Laracon EU 2025 – Amsterdam, The Netherlands, February 3-4. CFP 🆕
PHP UK Conference 2025 – London, UK, February 19. CFP 🆕
php[tek] 2025 – Chicago, IL, USA, May 20-22. CFP 🆕

To find a PHP meetup happening near you, check out the calendar on php.net.

Fun

JavaScript Bloat in 2024 by Niki Tonsky – “Gitlab needs 13 MB of JS code just to display a static landing page.”

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/Twitter.

Subscribe to PHP Annotated

Roman Pronskiy

Developer Advocate at @PhpStorm, Operations Manager at @The PHP Foundation.

Twitter | GitHub

PhpStorm : The IDE that empowers PHP developers | The JetBrains Blog

Read More

Latest News

PHP-Releases

PHP 8.2.24 released!

PHP 8.3.12 released!

Generated by Feedzy