ft/attributes

Catalog of PHP attributes like json, logging and property validation

2.2.2 2023-02-14 02:48 UTC

This package is auto-updated.

Last update: 2024-12-14 07:10:31 UTC


README

A catalog of php attributes for flexible and maintainable modeling.

Attributes for logging, json, property validation and more.

Quick example of property validation:

final class MyClass {
    use PropertyValidator;

    #[Email]
    private string $email;

    #[Min(value: 12)]
    private int $age;

    #[Size(min: 1, max: 3)]
    private array $phone_numbers;
}

Quick example of json:

class MyClass {
    private int $id = 1;
    #[JsonIgnore]
    private string $ssn = "xxx-xx-xxxx";
}

Json::encode(new MyClass); // { "id" : 1 }

For complete documentation and attribute usages see the documentation wiki