PHP code example of maxodrom / yii2-redis-ipban

1. Go to this page and download the library: Download maxodrom/yii2-redis-ipban 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/ */

    

maxodrom / yii2-redis-ipban example snippets


return [
    //....
    'components' => [
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0,
        ],
    ]
];

'modules' => [
    'redis-ip-ban' => [
        'class' => 'maxodrom\redis\ipban\Module',
        'redis' => 'redis',
        'allowedIPs' => [], // dont't check IPs, otherwise you can use for example this array ['127.0.0.1', '::1']
        'allowedRoles' => ['SuperAdmin'], // but check RBAC roles!
    ],
    ...
]

/**
 * @inheritdoc
 */
public function behaviors()
{
    return [
        ...,
        'ipban' => [
            'class' => \maxodrom\redis\ipban\filters\RedisIpBan::className(),
            'redis' => Yii::$app->redis,
        ],
    ];
}