PHP code example of fgreinus / antonioribeiro-firewall

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

    

fgreinus / antonioribeiro-firewall example snippets


Route::group(['middleware' => 'fw-block-bl'], function () 
{
    Route::get('/', 'HomeController@index');
});

Route::group(['middleware' => 'fw-block-bl'], function () 
{
    Route::get('coming/soon', function()
    {
        return "We are about to launch, please come back in a few days.";
    });

    Route::group(['middleware' => 'fw-allow-wl'], function () 
    {
        Route::get('/', 'HomeController@index');
    });
});

$ip = '10.17.12.1';

$whitelisted = Firewall::isWhitelisted($ip);
$blacklisted = Firewall::isBlacklisted($ip);

Firewall::whitelist($ip);
Firewall::blacklist($ip, true); /// true = force in case IP is whitelisted

if (Firewall::whichList($ip))  // returns false, 'whitelist' or 'blacklist'
{
    Firewall::remove($ip);
}

php artisan tail

php artisan firewall:blacklist country:br

'Firewall' => PragmaRX\Firewall\Vendor\Laravel\Facade::class,

php artisan firewall:tables

php artisan migrate

php artisan config:publish pragmarx/firewall

php artisan vendor:publish