PHP Annotated – December 2023

Welcome to the December edition of PHP Annotated! In it, we look back over some of the most interesting developments in the PHP community during the past month, featuring handpicked news, articles, tools, and videos.

Highlights

PHP 8.1.27, PHP 8.2.14, and PHP 8.3.1 released

🐛 These are bug-fix updates.

The PHP 8.1 branch has reached the end of its active support phase and will now only receive security-fix updates.

FrankenPHP v1.0 is out

A modern PHP application server written in Go, FrankenPHP gives you a production-grade PHP server with just one command. It includes native support for Symphony, Laravel, WordPress, and more.

Check out a video overview of FrankenPHP.

Support for FrankenPHP has been added to Laravel Octane.

The Future of PHP_CodeSniffer

The original maintainer of CodeSniffer decided to abandon the project, but fortunately a prominent community member, Juliette Reinders Folmer, moved the development to a new dedicated org, PHPCSStandards. Work on the tool will continue in PHPCSStandards/PHP_CodeSniffer.

The composer package name will not change for now; there is no need to change your dependencies.

Juliette and contributors have already delivered PHP_CodeSniffer 3.8.0 with tons of enhancements.

PHP_CodeSniffer is a community project and it needs financial support. If you’re using it for your work, consider sponsoring the maintainers: opencollective.com/php_codesniffer.

PhpStorm 2023.3 released

This major update brings AI Assistant, complete PHP 8.3 support, Pest support, improvements for Symfony, and other features. Check out this quick video overview.

Xdebug 3.3.0 is out
This release adds support for PHP 8.3, flame graphs, and control sockets.

For flame graph visualization, you can use speedscope.app.

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 include a few brief mentions:

📣 RFC: #[NotSerializable]

Max Semenik proposes to add a new #[NotSerializable] attribute to prevent the class from serialization. Currently, to achieve similar behavior you need to throw exceptions in __wakeup() and __sleep(). If this RFC is accepted, the code will be cleaner and better lend itself to being analyzed by static analyzers:

#[NotSerializable]class MyClass
{
}

serialize(new MyClass()); // Exception: Serialization of ‚MyClass‘ is not allowed

📣 RFC: Policy Repository

Currently, policies in regard to RFC Voting, the Release Process, security classification, and naming guidelines are all stored in different places.

Derick Rethans proposes to set up a new Git repository to collect all the policies in one place.

❌📣 RFC: Final anonymous classes

The RFC was rejected, partly due to the unclear voting question.
After the feedback, Daniil Gentili proposed a new RFC: Final-by-default anonymous classes.

He suggests making all anonymous classes final by default and providing a new open keyword to make them non-final if needed. This is similar to Kotlin’s new open class {}. The chances that this proposal will be accepted appear to be quite low.

RFC: Change how JIT is disabled by default

Currently, JIT is disabled when opcache.jit_buffer_size is set to 0. PHP 8.4 will have a separate setting for that with the following default: opcache.jit=disable.

PR: new MyClass()->method() without parentheses
Valentin Udaltsov suggested removing unnecessary parentheses in object initialization expressions, which triggered a heated discussion on X (formerly known as “Twitter”).

new MyClass()->method() without parentheseshttps://t.co/ZslOGSaIzX

What are your thoughts?

pic.twitter.com/J6uWKXdnYj

— Roman Pronskiy (@pronskiy) December 26, 2023

New PECL is coming in 2024
The PHP Foundation is about to rework how extensions are installed in PHP.

Currently, extensions are distributed using the pecl.php.net legacy website and the pecl tool. The goal is to provide a modern alternative that is easier to use for both users and extension maintainers.

Tools

staabm/phpstan-todo-by – A tool that allows you to leave ‘todo’ comments with expiration dates. TIL that there are programming languages, such as Gleam, that provide todo as a language feature.

spatie/image v3 – Manipulate images with an expressive API. V3 no longer depends on league/glide. New major versions for spatie/image and Laravel Media Library have been released by Freek Van der Herten.

bpolaszek/bentools-etl – An ETL (Extract / Transform / Load) library with SOLID principles + almost no dependencies.

samdark/php-fpm_tuner – A script that helps tune PHP-FPM configs based on available memory, CPU cores, and how much memory workers are consuming.

The author of the tool has a nice Telegram channel. That’s where I learned that PHP and other scripting languages are slower on Alpine than on Debian because of the musl vs glibc memory management variance. If you want to read up on this, look here: Why is the Alpine Docker image over 50% slower than the Ubuntu image?

super-linter/super-linter – A combination of linters that can be installed as a GitHub Action. This could be useful if you have polyglot projects.

gherkins/regexpbuilderphp – A human-readable regular expression builder.

maximal/taran – A simple tool for load testing web applications.

serversideup/docker-php – Production-ready Docker images for PHP.

OrbStack – A lightweight alternative to Docker Desktop.

mnapoli/sqlite-s3 – A serverless dev database: SQLite backed by S3.

typhoon-php/overloading – Implementing the missing method overloading feature for PHP.

Symfony

Master task scheduling with Symfony Scheduler by Baptiste Leduc.

Introducing the Symfony 7 Certification by Javier Eguiluz.

Improving cohesion in Symfony – storing Twig templates with the code by Ben Roberts.

❗️The last Twig 2 release by Fabien Potencier.

yceruto/bundle-skeleton – A minimal Symfony bundle recommended for creating new bundles.

Symfony 2023 Year in Review.

Laravel

Creating a custom Laravel Pulse card by Aaron Francis.

The ultimate guide to Laravel’s new Number helper by Benjamin Crozat.

PHP attributes in Laravel by Mater Oussama.

Hands-on decoration by Muhammed Sari.

API Versioning in Laravel: The Complete Guide to Doing it Right by Steve McDougall.

HPWebdeveloper/laravel-pay-pocket – A multi-wallet Laravel package with comprehensive logging and payments capabilities.

rmunate/PHP2JS – Share PHP Laravel values effortlessly with external JavaScript files using just one command.

Caching Strategies In Laravel by Jamison Valenta.

How to process large CSV files with Laravel by Lokman Musliu.

Uploading files directly from client to S3 without files ever touching your Laravel application by Josip Crnković.

Rendering Blade components in Markdown by Aaron Francis.

How to build a SaaS in a weekend by Arunas Skirius.

cloudstudio/ollama-laravel – Ollama-Laravel is a Laravel package providing seamless integration with the Ollama API. Ollama allows you to run Llama 2 and other large language models locally.

laravel-shift/blueprint – A code generation tool for Laravel developers.

Other frameworks

Service Locator vs Dependency Injection by Wilmer Arambula.

Vertical Slice Architecture in PHP by Wilmer Arambula.

State of the WordPress 2023 Recap by Matt Mullenweg.

Misc

Creating Standalone PHP App Binaries using Static PHP CLI by Bosun Egberinde – It’s great to see the idea getting more interest among the community.

FrankenPHP also allows you to pack your PHP app in a single binary using the same approach described above.

Mercure, Braid, PREP… news about subscribing to HTTP resource updates by Kévin Dunglas.

The Evolving Landscape of API Protocols in 2023 by Alex Xu – A nice overview of popular approaches to APIs: REST, Webhooks, GraphQL, SOAP, WebSocket, gRPC, and others.

Cutting through the static by Larry Garfield.

Array, classes and anonymous classes memory usage by Damien Seguy.

Working with decimals in PHP apps by Mark Scherer.

Testing Abstract Classes in PHP using Anonymous Classes by Christian Olear.

Logging Layers: A Guide to Structured and Consistent Logging by Hamidreza Niazi.

PHP Dictionary by Damien Seguy – This doc provides a list of words, concepts, keywords, and expressions used commonly in the PHP ecosystem, with a short definition and extra links to more resources.

PHP enums are really growing on me

Check this out:

A PHP enum with a „->dates()“ method so that each case can return it’s own carbon instances

pic.twitter.com/VmGJ74UGKu

— Caleb Porzio (@calebporzio) December 18, 2023

Fun

Sylius elePHPant is available for preorder on Kickstarter.

😂 This made me chuckle… welcome to #PHP 8.3 !

First array is the type, the second is the name of the constant, with the relaxed keyword, and the last one is the value of the array.#phptip #phptrick

pic.twitter.com/0aL2tpBAsj

— Damien Seguy (@[email protected]) (@faguo) December 6, 2023

Here is a #PHP 8.3 fully compatible code. No @phpstan error (level 9, Strict rules and Bleeding edge: https://t.co/lUpng5Yiph)

Where are my braces? #goto #oldSchool

pic.twitter.com/uZLUZaPARG

— Frédéric Bouchery 🌟 (@FredBouchery) December 19, 2023

Conferences

These PHP events are all worth a visit (and feel free to apply as a presenter at any of them as well):

Laracon EU – Amsterdam, the Netherlands, Feb 5–6, 2024. CFP
PHP UK – London, UK, February 15–16, 2024. CFP
Dutch PHP Conference – Amsterdam, the Netherlands, March 12–15, 2024.
Laracon India – Udaipur, India, March 23–24, 2024. CFP 🆕
PHP[TEK] 2024 – Chicago, IL, USA, April 23–25, 2024. CFP 🆕
phpday 2024 – Verona, Italy, May 16–17, 2024. CFP 🆕
International PHP Conference – Berlin, Germany, May 27–31, 2024 CFP 🆕

Happy holidays, PHPers! 🎄🐘

If you have any interesting or useful links to share via PHP Annotated, please leave a comment on this post or send us a tweet.

Subscribe to PHP Annotated

Roman Pronskiy

Developer Advocate at the @PhpStorm team, Operation Manager at @The PHP Foundation.

Twitter | GitHub

The PhpStorm Blog : The Lightning-Smart IDE for PHP Programming | The JetBrains Blog

Read More

Latest News

PHP-Releases

PHP 8.2.25 released!

PHP 8.3.13 released!

Generated by Feedzy