PHP code example of particleflux / yii2-blocklist-validator

1. Go to this page and download the library: Download particleflux/yii2-blocklist-validator 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/ */

    

particleflux / yii2-blocklist-validator example snippets


public function rules(): array
{
    return [
        ['username', BlockListFileValidator::class, 'file' => '@app/config/bad-usernames.txt'],
    ];
}

public function rules(): array
{
    return [
        [
            'username',
            BlockListFileValidator::class,
            'file' => '@app/config/bad-usernames.txt'   // the path to the blocklist file, can contain aliases
            'strict' => true,           // whether to do strict comparison (default: false)
            'useCache' => true,         // use cache component defined in 'cache' (default: true)
            'cacheTtl' => 60,           // cache TTL (default: null, meaning the component default)
            'cache' => 'customCache',   // cache component to use (default 'cache')
        ],
    ];
}