PHP code example of prinsfrank / php-validated-properties

1. Go to this page and download the library: Download prinsfrank/php-validated-properties 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/ */

    

prinsfrank / php-validated-properties example snippets


#[Url]
protected string $url;

#[Between(1, 100)]
protected int $nrOfItems;

#[Email]
protected string $email;



use PrinsFrank\PhpStrictModels\Model;

class ValidatedModel extends Model {

}



use PrinsFrank\PhpStrictModels\WithValidatedProperties;
use Illuminate\Database\Eloquent\Model;

class ValidatedModel extends Model {
    use WithValidatedProperties;
}



use PrinsFrank\PhpStrictModels\Model;
use PrinsFrank\PhpStrictModels\Rule\Between;
use PrinsFrank\PhpStrictModels\Rule\Url;

class ValidatedModel extends Model {
    #[Between(1,5)]
    protected int $nrOfItems;
    
    #[Url]
    protected string $url;
}
shell
composer 
prinsfrank/php-validated-properties-phpstan
neon
 - vendor/prinsfrank/php-validated-properties/development/PHPStan/extension.neon