PHP code example of rahulalam31 / laravel-abuse-ip

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

    

rahulalam31 / laravel-abuse-ip example snippets


    use Illuminate\Support\Facades\Schedule;
    //
    Schedule::command('abuseip:update')->daily();
    

     protected function schedule(Schedule $schedule)
     {
         $schedule->command('abuseip:update')->daily();
     }
    

//Laravel 10 and below
/*
 * app/Http/Kernel.php
*/

protected $middleware = [
        \RahulAlam31\LaravelAbuseIp\Middleware\AbuseIp::class,
        .....
]



//Laravel 11
/*
 * bootstrap/app.php
*/
->withMiddleware(function (Middleware $middleware) {
        $middleware->append(\RahulAlam31\LaravelAbuseIp\Middleware\AbuseIp::class);
    })


//Laravel 10 and below
/*
 * app/Http/Kernel.php
*/

protected $routeMiddleware = [
        .....,
        'abuseip' => \RahulAlam31\LaravelAbuseIp\Middleware\AbuseIp::class,

]

Route::get('/xyz', function () {
    //
})->middleware('abuseip');

//Laravel 11
/*
 * bootstrap/app.php
*/

->withMiddleware(function (Middleware $middleware) {
    //
})
->aliasMiddleware('abuse_ip', \RahulAlam31\LaravelAbuseIp\Middleware\AbuseIp::class)


// Or use in route file

Route::middleware(AbuseIp::class)->get('/', function () {
            return view('welcome');
        });

bash
    php artisan vendor:publish --tag=laravel-abuse-ip
    
bash
    php artisan abuseip:update