taknone / attributes
Attribute-based validation for PHP 8.3+
Installs: 47
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/taknone/attributes
README
Attribute-based validation for PHP 8.3+ : validate method parameters, return values and property access using compact, reusable attributes
Validator — Declarative validation using PHP 8+ 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
📦 Installation
Install via Composer :
composer require taknone/attributes
Then enable Composer autoload in your project :
require_once __DIR__.'/vendor/autoload.php';
🚀 Quickstart
The repository includes an examples
directory with runnable examples and small helper scripts
Contributing
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 )
License
MIT — see LICENSE
Support / Contact
If you need help integrating Attributes
into your project, open an issue or reach out via the repository's issue tracker