
A clean API for reading PHP attributes | freek.dev
PHP 8.0 introduced attributes, and they're a great way to add structured metadata to classes, methods, properties, constants, and parameters. The concept is solid, but the reflection API you need to actually read them is surprisingly verbose. What should be a simple one-liner ends up being multiple lines of boilerplate every time. And if you want to find all usages of an attribute across an entire class, you're looking at deeply nested loops.
We just released spatie/php-attribute-reader, a package that gives you a clean, static API for all of that. Let me walk you through what it can do.
freek.dev@freekmurze Oh good. Another Laravel library that duplicates functionality that already exists in a framework independent way, for years.
https://github.com/Crell/AttributeUtils/

GitHub - Crell/AttributeUtils: Utilities to help ease parsing and manging of attributes
Utilities to help ease parsing and manging of attributes - Crell/AttributeUtils
GitHub@Crell @freekmurze ... but this doesn't appear to have any dependencies on Laravel? ¯\_(ツ)_/¯
https://github.com/spatie/php-attribute-reader

GitHub - spatie/php-attribute-reader: A clean API for working with PHP attributes
A clean API for working with PHP attributes. Contribute to spatie/php-attribute-reader development by creating an account on GitHub.
GitHub@ralphschindler @freekmurze Well that's novel. Still a duplicate of an existing, maintained library.
@Crell @freekmurze competition between open source libraries is alive and well! 😉