PHP code example of ft / attributes

1. Go to this page and download the library: Download ft/attributes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ft / attributes example snippets


final class MyClass {
    use PropertyValidator;

    #[Email]
    private string $email;

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

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

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

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