1.3 KiB
title | date | permalink | tags | cta | snippet | |||
---|---|---|---|---|---|---|---|---|
PHP attributes: coming soon to a Drupal version near you | 2024-04-04 | daily/2024/04/04/php-attributes--coming-soon-to-a-drupal-version-near-you |
|
~ | Have you used PHP attributes in Drupal yet? They've started to be available for some plugin types since version 10.2. |
Since Drupal 10.2, the framework has started to adopt PHP attributes - a new feature since PHP 8 - as an alternative to annotations when defining plugins, such as blocks and queues.
From the 10.2 release notes:
Drupal core has started adopting PHP attributes, a modern PHP language feature, to provide better developer experience for plugin annotations. Contributed and custom code can begin adopting this improved API for their plugins, and Block and Action plugins can all be converted to the new API.
It seems that what's been added so far is the first phase of converting the core's plugins, with more to follow in future versions.
There are also discussions about supporting both attributes and annotations in Drupal 11.
I love to see Drupal continuing to evolve and adopt new features from the PHP language and Symfony framework (such as autowiring and autoconfiguration), and I'm looking forward to using attributes in my projects.