Attribute-based validation for PHP 8.3+ : validate method parameters, return values and property access using compact, reusable attributes
A lightweight, framework-agnostic library that lets you declare validation rules as PHP attributes. Validate method parameters, method return values, and property get/set using compact, reusable attribute classes (for example #[Range]
, #[Pattern]
, #[Vector]
). Built-in caching of reflection metadata keeps runtime overhead low
Install via Composer :
composer require taknone/attributes
Then enable Composer autoload in your project :
require_once __DIR__.'/vendor/autoload.php';
The repository includes an examples
directory with runnable examples and small helper scripts
PRs welcome ! Follow a few rules :
- Run and add example for new validators
- Keep attribute constructor arguments constant expressions ( required by PHP attributes )
- Document behavior for corner cases ( nullability, casting, unique semantics )
MIT β see LICENSE
If you need help integrating Attributes
into your project, open an issue or reach out via the repository's issue tracker