PHP code example of olssonm / blockip

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

    

olssonm / blockip example snippets

 php


    'providers' => [
        Olssonm\Blockip\BlockipServiceProvider::class
    ]
 php


    Route::group(['middleware' => 'blockip'], function() {
        Route::get('/', ['as' => 'start', 'uses' => 'StartController@index']);
        Route::get('/page', ['as' => 'page', 'uses' => 'StartController@page']);
    });
 php


    Route::get('/', [
        'as' => 'start',
        'uses' => 'StartController@index',
        'middleware' => 'blockip'
    ]);
 php


use Olssonm\Blockip\Handlers\BaseHandler;

class MyHandler implements BaseHandler {

    /**
     * @return string
     */
    public function getIp() {
        // Method to retrieve the request IP
    }

    /**
     * @return array
     */
    public function getIpsToBlock() {
        // Method to set what IPs to be blocked
    }

    /**
     * @return response
     */
    public function getError() {
        // Method to set the response
    }
}