PHP Annotated – November 2023
Welcome to the November 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.3.0 released!
PHP 8.3 is a major update of the PHP language. It contains new features, such as typed class constants, deep-cloning of readonly properties, and additions to the random functionality. As always, it also includes performance improvements, bug fixes, and a general cleanup.
For a detailed list of what’s new in PHP 8.3, check out the release page, the migration guide, and learn a little more about the release in the PHP Foundation’s announcement.
Install or upgrade to PHP 8.3
- Windows: Compiled binaries can be found at windows.php.net. Alternatively, you can opt for a community build available on Chocolatey.
- Ubuntu/Debian: PHP 8.3 is available on ondrej/php PPA.
- Fedora/RHEL/CentOS: Available as a software collection (php83) from the Remi repo.
- macOS: PHP 8.3 can be installed via Homebrew using the shivammathur/homebrew-php tap.
- Docker: PHP 8.3 images are now available on Docker Hub with 8.3 tags.
PhpStorm already supports PHP 8.3.
Watch a 📺 Celebrating PHP 8.3 stream with Freek, Brent, and Roman.
- ⚠️ PHP 8.0 has reached end of life
PHP 8.0.30 marked the last release of PHP 8.0. It will no longer receive official security updates.
- PHP 8.1.26 and PHP 8.2.13 have been released
🐛 These are bug-fix releases.
The PHP 8.1 branch will receive one more release, PHP 8.1.27, which will be the last bug-fix release, with only security bug fixes being released thereafter.
- 🎂 The PHP Foundation turns two
The PHP Foundation was established two years ago.Over the past year, the PHP Foundation has supported the work of six core developers, and made a significant contribution to the PHP language.
Check out the PHP Foundation’s November 2023 Update.
Consider supporting the PHP Foundation via OpenCollective or GitHub Sponsors.
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 make a few brief mentions:
- 📣 RFC: Resource to object conversion
Resource
is an obsolete data structure in PHP that has long since been superseded by objects. Work on replacing resources with objects started back in 2013, but most extensions only migrated with the release of PHP 8.0.Máté Kocsis suggests migrating the remaining extensions and defining a policy for future development.
- 📣 RFC: Release cycle update
Currently, the lifetime of a PHP version is 3 years. Many people consider this to be too short, and the pre-release phase, which is six months, excessively long.Jakub Zelenka, the PHP 8.3 release manager, proposes to increase the PHP version lifetime to 4 years (2 years of maintenance and 2 years of security updates) and to revise the pre-release phase.
- 📣 RFC: Improve callbacks in ext/dom and ext/xsl
Niels Dossche proposes to allowXSLTProcessor::registerPHPFunctions()` and `DOMXPath::registerPhpFunctions()` methods to use `callable
. - 📣 RFC: Change how JIT is disabled by default
Currently, JIT is running intracing
mode, but disabled by default whenopcache.jit_buffer_size
is set to0
. RFC suggests disabling JIT by default by settingopcache.jit=disable
, and increasing the defaultjit_buffer_size
value to64m
. - 📣 RFC: Final anonymous classes
1. Add support for final anonymous classes (
new final class {}
syntax, no breaking changes).
2. OR Make all anonymous classes final by default, without the option to make them final (breaking change)
3. OR Make all anonymous classes final by default, provide an optional `open` keyword to make them non-final (like in Kotlin,new open class {}
, breaking changes). - 📣 RFC: Property Hooks
In this RFC, Ilija Tovillo and Larry Garfield propose to declare virtual properties with get/set functions.The design and syntax is most similar to Kotlin, although it also draws influence from C# and Swift.
class User implements Named { private bool $isModified = false; public function __construct(private string $first, private string $last) {} public string $fullName { get => $this->first . " " . $this->last; set($value) => [$this->first, $this->last] = explode(' ', $value); } }
Interesting side effect of this RFC is that it allows to declare abstract properties in interfaces:
abstract class A { abstract public string $readable { get; } abstract protected string $writeable { set; } abstract protected string $both { get; set; } } class C extends A { public string $readable; protected string $readable; protected string $writeable { set => $field = $value; } public string $both; }
Thanks to Sjon Hortensius, you can already try property hooks on 3v4l.org.
And you can also provide your feedback on RFC Vote: Property Hooks.
Tools
- php-tui/php-tui – A framework for creating console applications in PHP with pseudo graphical UI.
- Crell/Serde – A robust serialization/deserialization library for PHP 8.
- pestphp/pest-plugin-stressless – A stress load testing plugin for Pest built on top of grafana/k6. See the introductory video 📺 Stressless: Stress Testing for PHP.
- buggregator/server – A lightweight, standalone server that offers a range of debugging features for PHP applications, including XHprof profiler, Symfony VarDumper server, SMTP server, Sentry-compatibile server, Monolog server, and HTTP requests dump server.
It comes with buggregator/trap – a console mini-server and helper for more convenient debugging in PHP.
- NoiseByNorthwest/php-spx – A simple and straight-to-the-point PHP profiling extension with its built-in web UI.
- reliforp/reli-prof – A sampling profiler or a memory profiler for PHP written in PHP, which reads information about running PHP VM from outside the process. You can find performance bottlenecks or memory leaks in your scripts without changing the target script or loading extensions.
Alternatively, you can try arnaud-lb/php-memory-profiler – A memory profiler extension for PHP. It helps find memory leaks in PHP scripts.
- saloonphp/xml-wrangler – A simplistic PHP library designed to make reading and writing XML easy. See also veewee/xml – A package that provides all the tools you need for worry-free work with XML in PHP.
- jolicode/JoliMarkdown – A syntax fixer for markdown content. Read Introducing JoliMarkdown for more details.
- cerbero90/lazy-json – A framework-agnostic package to recursively load JSON files of any dimension and any source into Laravel lazy collections.
- staabm/phpstan-baseline-analysis – Analyzes PHPStan baseline files and creates aggregated error trend-reports.
- spiral/json-schema-generator – Provides the ability to generate JSON schemas from Data Transfer Object (DTO) classes.
Symfony
- Symfony 7 released
Check out the Living on the edge list to learn about new features in this release. Or check out these Hello Symfony 7 slides by Alexander M. Turek.Symfony 6.4 has also been released along with 7.0. Both versions contain the same set of features, except for support for deprecated features.
Also, Symfony 6.4 is a long-term support version that will get bug fixes for 3 years and security bugs for another 1 year. Symfony 7.0 is a regular version that will only be supported for 8 months.
- Making a Single-Page Application with HTMX and Symfony by Julien Cousin-Alliot.
- A retry mechanism for Symfony commands by Smaine Milianni.
- phpyh/service-dumper-bundle – Symfony console command to dump dependency injection services.
Laravel
- Laravel Pulse announced – The Laravel team revealed an upcoming free and open-source tool. It will be a dashboard with key performance and usage metrics for your app.
- Tinkerwell v4 is now out – Check out this 📺 Detail Dive.
- MongoDB Laravel Integration Now Officially Supported – MongoDB has taken over development of the community-driven MongoDB integration for Laravel, making it a first-class citizen in their product portfolio.
- How does Laravel work? A crystal clear explanation by Benjamin Crozat.
- My process for writing Laravel packages by David Carr.
- Unorthodox Eloquent II by Muhammed Sari.
- Caching Strategies In Laravel by Jamison Valenta.
- laravel/pail – A tool to view Laravel logs in the terminal in a convenient way.
- waterholeforum/core – A Laravel-powered community platform / forum.
- BookStackApp/BookStack – A platform to create documentation/wiki content built with PHP and Laravel.
Other Frameworks
Misc
- Best Practices for Using PHP Enumerations by Jeff Ochoa.
- Migrating from PER-CS v1.0 (PSR-12) to PER-CS v2.0 by PHP-FIG.
- HTTP/3 Request with PHP Curl Extension by Ayesh Karunaratne.
- How to use Caddy Server with PHP by Ayesh Karunaratne.
- Working with decimals in PHP apps by Mark Scherer.
- Type Safety Done Right – PHP Array Hacking by James Seconde.
- Phpstan Filter Baseline by Markus Staab – One way to work through a huge PHPStan baseline.
- Curated a list of PHP YouTubers.
- Autonomous Hacking of PHP Web Applications at the Bytecode Level by Samuel Finixbit.
- Bref case study: How Treezor runs a serverless banking platform with Bref – They started with a legacy PHP monolith on servers, put the monolith in Lambda (aka "a bank in a Lambda"), and then transitioned to microservices.
- Mastering the (array) Cast Operator in PHP: A Comprehensive Guide by Damien Seguy.
- WP-Plugin-Architect – Custom (Chat)GPT that can write WordPress plugins, while paying special attention to code security.
-
Cool #gpt trick I learned from a friend today:
1) create a private GPT
2) upload your #php project in a zip
3) ask it questions on how to improve itWho knew this goes far beyond the 128k context window 😎
The results are impresive… feels like talking to myself with having… pic.twitter.com/nlOyFlmQ70
— Tomas Votruba (@VotrubaT) November 16, 2023
Fun
- Sylius is now offering their ElePHPant in a crowdfunding campaign on Kickstarter.
- The Original Pink Elephpant is available for sale.
Conferences
Check out these upcoming PHP gigs worth visiting and applying to present at:
- SymfonyCon – Brussels, Belgium, December 7–8, 2023.
- Laracon EU – Amsterdam, The Netherlands, Feb 5–6, 2024.
- PHP UK – London, UK, February 15–16, 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
If you’re wondering when the next PHP meetup near you is happening, Tomas Votruba has got you covered with his lovely friendsofphp.org meetup aggregator. There is also a calendar on php.net.
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 us a tweet.