PHP code example of michaelnabil230 / laravel-block-ip

1. Go to this page and download the library: Download michaelnabil230/laravel-block-ip 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/ */

    

michaelnabil230 / laravel-block-ip example snippets


protected function configureRateLimiting()
{
    RateLimiter::for('api', function (Request $request) {
        return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
    });

    \MichaelNabil230\BlockIp\BlockIpRegistrar::rateLimiter();
}

protected $middlewareAliases = [
    // ...
    'block-ip' => \MichaelNabil230\BlockIp\Middleware\BlockIpMiddleware::class,
];

Route::middleware(['block-ip', 'throttle:block-ip'])->group(function () {
    // Your protected routes here
});
bash
php artisan block-ip:install
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-block-ip-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-block-ip-config"
bash
php artisan block-ip:unblock --ips=127.0.0.1,127.0.0.2