constup-foss / php-attributes
A collection of PHP attributes and their processors.
Requires
- php: >=8.5
Requires (Dev)
- fakerphp/faker: ^1.24
- friendsofphp/php-cs-fixer: ^3.95
- phpunit/phpunit: ^13
This package is auto-updated.
Last update: 2026-05-20 10:39:02 UTC
README
Table of ContentsDescription
A collection of PHP attributes and their processors.
The main idea behind several attributes in this library is to leverage First Class Callables in static expressions (PHP RFC Wiki) introduced in PHP 8.5. FCCs allow you to have attributes whose arguments are not static, but rather resolved during runtime. This removes the clutter of having multiple distinct attributes to cover the same base functionality, for example, validation.
Of course, since this approach has its benefits and downsides, this library contains classic attributes with static arguments. You are free to use the ones that are the best fit for your use case.
Supporting development
If you like this library or find it useful, consider buying me a nice cup of coffee. Coffee fuels open source.
Installation
composer require constup-foss/php-attributes
Available attributes
#[DoNotSerialize] #[TransformPropertyName(\Closure $transformer)] #[TransformPropertyValue(\Closure $transformer)] #[ValidateProperty(\Closure $validator)]
More detailed list of available attributes, their processors and links to individual documentation pages is available here: Available attributes
License
MIT License
-
License file: LICENSE.txt
-
Online version: https://opensource.org/license/mit
Supporting development
If you like this library or find it useful, consider buying me a nice cup of coffee. Coffee fuels open source.
