PHP Annotated – December 2022
Greetings everyone!
Welcome to the December 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 released!
PHP 8.2 is a major update of the PHP language.It contains new features, including readonly classes, DNF types,null
/false
/true
as stand-alone types, a new randomizer API, and constant in traits.The release comes with a few deprecations, with the deprecated dynamic properties being probably the most significant one. There are also performance improvements, as usual.
For a detailed list of what’s new in PHP 8.2, check out the release page.
Also check out PHP 8.2 Highlights on PHP.Watch and a video overview of PHP 8.2 by my colleague Brent.Installing/Upgrading to PHP 8.2
- Windows: Compiled binaries are available at windows.php.net.
- Ubuntu/Debian: PHP 8.2 is available on ondrej/php PPA. A detailed installation/upgrade guide is available on PHP.Watch.
- Fedora/RHEL/CentOS/Alma/Rocky: Available as a software collection php82 from the Remi repo.
- Mac OS: PHP 8.2 can be installed via Homebrew with shivammathur/homebrew-php tap.
- Docker: PHP 8.2 images are now available on Docker Hub with 8.2* tags.
- ⚠️ PHP 7 has reached end of life
PHP 7.4.33 was the last release of PHP 7. PHP 7 will no longer receive official security updates.However, major distributions like RedHat or Ubuntu will deliver security updates for PHP 7.4 as part of their LTS premise.
- PHP 8.0.26 and PHP 8.1.13 have been released
🐛 These are bug fix releases.The PHP 8.0 branch has ended active support, and will only receive security-fix updates.
- 🎂 PHP Foundation turns 1 year
The PHP Foundation was established a year ago.Over the past year, the PHP Foundation has supported the work of 6 core developers, and made a significant contribution to the PHP language.
Check out the Impact and Transparency Report 2022 to learn what has been achieved and see the high-level goals for 2023.
Consider supporting the PHP Foundation via OpenCollective.
- PhpStorm 2022.3 is out
This major update brings a preview of the new UI, complete PHP 8.2 support, Redis support in database tools, Code Vision for PHP, a quick-fix preview, Xdebug config validation, support for ParaTest, reader mode for PHPDoc, and many other features. - Symfony 6.2 is out
Better emoji support, an access token authenticator, built-in Cache+Security+Template+Doctrine Attributes, improved enum support, and more.Check out the Curated New Features list to learn about the highlights of this new release.
- 📺 PHP Annotated on YouTube
In addition to this PHP Annotated Newsletter, we now also have a dedicated PHP Annotated channel on YouTube.The channel is all about PHP and community, and you can check out the first videos by Brent Roose.
- ✅ PSR-20: Clock accepted
The PHP-FIG group has accepted and tagged a PSR-20 with the recommendedClockInterface
for date and time. - 🎉 Psalm 5 is out
There are a few new features available in this release:list{int, string, float}
,properties-of
, variable templates, andint-range<x, y>
. - Xdebug 3.2.0 is out
This release adds support for PHP 8.2, and drops support for PHP 7.2-7.4. It has the new ability to inspect function return values, and comes with better warning messages. - PHPStan 1.9.0 has been released
The update brings PHPDoc asserts, list types, @param-out tag for parameters assigned by referencу, and other improvements. - Drupal 10 is available
It requires Symfony 6.2 and PHP 8.1 and adds many improvements across all systems.
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:
- 📣 PHP RFC: Dynamic class constant fetch #PHP 8.3
Ilija Tovilo proposed introducing a syntax for looking up class constants.class Foo { const BAR = 'bar'; } $bar = 'BAR'; // This is currently a syntax error echo Foo::{$bar}; // Instead, the `constant` function must be used echo constant(Foo::class . '::' . $bar);
- 📣 RFC: Arbitrary static variable initializers #PHP 8.3
Ilija Tovilo proposed extending the syntax that allows the static variable initializer to contain arbitrary expressions.function bar() { echo "bar() called\n"; return 1; } function foo() { static $i = bar(); echo $i++, "\n"; } foo();
- 📣 RFC: Readonly amendments #PHP 8.3
Nicolas Grekas and Máté Kocsis proposed improving readonly properties and classes, allowing non-readonly classes to extend readonly classes and allowing readonly properties to reinitialize during cloning:readonly class Foo { public function __construct( public DateTime $bar ) {} public function __clone() { $this->bar = clone $this->bar; } } $foo = new Foo(new DateTime()); $foo2 = clone $foo;
- 📊 RFC: More Appropriate Date/Time Exceptions #PHP 8.3
Derick Rethans proposed introducing Date/Time extension specific exceptions and errors where this makes sense. - 📣 RFC:
List\unique()
andAssoc\unique()
Ilija Tovilo proposed adding two new functions for the cases that are not supported byarray_unique()
:List\unique([1, 2, 3, 1, '2', 3.0, new Foo, ['bar']]); // > [1, 2, 3, '2', 3.0, Foo, ['bar']] Assoc\unique(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'foo']); // > ['foo' => 'foo', 'bar' => 'bar']
- 📣 RFC: Unicode Text Processing #PHP 8.3
Derick Rethans suggests introducing a newText
class to make using and processing Unicode text significantly more developer friendly and without having to know all the intricacies of Unicode text processing.$content = new Text('नमस्ते दुनिया'); if ($content->toLower()->startsWith('नमस्ते')) { // ... }
Tools
- Marcel Pociot built a neat GitHub bot that evaluates PHP code blocks in GH issues if you mention it @phptinker:
- ramsey/uuid – A new version of package for generating universally unique identifiers comes with support for UUID v8 and custom UUIDs.
- loophp/collection – A memory friendly and modular collection class released a new major version, 7.0.0.
- php-rust-tools/parser – A work-in-progress PHP parser written in Rust by Ryan Chandler and Saif Eddin.
You may also be interested in phper, a tool that allows writing PHP extensions using pure and safe Rust whenever possible.
- ScriptFUSION/Porter – Durable and asynchronous data imports for consuming data at scale and publishing testable SDKs.
- ChatGPT is taking over everything, so you may want to check out the PHP client for OpenAI:
- openai-php/client – A supercharged PHP API client that allows you to interact with OpenAI API.
- orhanerday/open-ai – A PHP SDK for accessing the OpenAI GPT-3 API.
- qossmic/deptrac 1.0 – Project architecture analysis tool for determining dependencies between application layers.
- revoltphp/event-loop 1.0.0 – This event loop is a joint effort between ReactPHP and Amphp maintainers. It is now ready for production use, has been tested in various different applications and scenarios, and fully supports fibers.
-
Since years, I am annoyed about #PHP extensions with #docker. install-php-extensions helps, but still I need to compile the extensions.
So I build a docker registry, which magically adds a docker layer for each extension requested with image. This is experimental! pic.twitter.com/EjoptGhvRm
— Shyim (@shyim@phpc.social) (@Shyim97) December 1, 2022
- rob893/emoji-cache – LRU cache implementation, but all identifiers are emojis.
Symfony
- API rate liming per route in Symfony 6.1 by Christian Nielebock.
- Asserting the output of Symfony console commands by Andreas Möller.
- Discover Symfony UX components and enhance your front-end by Jakub Tobiasz.
- Centralized exception handling with Symfony and custom PHP attributes by Dejan Angelov.
Laravel
- Laravel best practices: the definitive guide for 2022 by Benjamin Crozat.
- Are Your Queue Workers … Working? by Jamison Valenta.
- Using Generators for Pagination by James Bannister.
- Unique jobs and reserving resources on the queue by Tim MacDonald.
- A Look at What’s Coming to Laravel 10 by Paul Redmond.
- Save 1 million queries with Laravel Eager Loading by Valerio Barbera.
- Rector rule set for Laravel – Even if you don’t use Rector, check out this link anyway! It has some interesting refactoring examples (diffs) for Laravel projects.
Other Frameworks
- Yii news 2022, issue 2 by Alexander Makarov.
- Yii3 Overview 1. Intro.
- Spiral 3.3.0 has been released – With a built-in OpenTelemetry support.
Misc
- 24 Days in December
Every year, for the first 24 days in December, members of the PHP community share their thoughts with us. Here are just a few worth mentioning:- Evolving PHP by Edward Barnard. “With the current pace of PHP development, userland cannot keep up. Something needs to give.”
- Being a developer is not the same as knowing how to code by Ben Scheffer.
- The PHP 8.2 Release Managers by Sergey Panteleev.
- An Ode to PHP by Nigel James.
- Generics via Attributes in PHP by Roman Pronskiy.
- From annotations to attributes by Grégoire Paris.
- How to Measure Your Type Coverage by Tomas Votruba.
- A story of Lazy Loading File System Operations for better dev system performance by Benjamin Eberlei.
Video
- 📺 Writing declarative PHP by Andrew Schmelyun.
- 📺 What’s New in PHP 8.2 by MergePHP.
- 📺 Guido van Rossum (creator of Python) and Lex Fridman discuss the $ sign in PHP variable names: Lex Fridman on PHP programming.
Conferences
- Laracon EU – Lisbon (Portugal), January 26–27, 2023.
- PHP UK Conference – London (UK), February 14–16, 2023.
- Php[tek] – Chicago (US), May 16–18, 2023.
- Laracon US – Nashville, TN, July 19–20, 2023.
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 me a tweet.