PHP code example of juanpagfe / slim-ip-filter

1. Go to this page and download the library: Download juanpagfe/slim-ip-filter 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/ */

    

juanpagfe / slim-ip-filter example snippets


$app = new \Slim\App();

$app->add(new RKA\Middleware\IpAddress());

$options = array(
    array(
        'ip' => '192.*.*.*',
        'allow' => false
        )
);

$app->get('/api/myEndPoint',function ($req, $res, $args) {
  //Your amazing route code
})->add(new \Jpgfe\Slim\IpFilter\RestrictRoute($options));

$app->run();

$app = new \Slim\App();

$app->add(new RKA\Middleware\IpAddress());

$options = array(
    array(
        'ip' => '192.*.*.*',
        'allow' => false
        )
);

// Register middleware for all routes
// If you are implementing per-route checks you must not add this
$app->add(new \Jpgfe\Slim\IpFilter\RestrictRoute($options));

$app->get('/foo', function ($req, $res, $args) {
  //Your amazing route code
});

$app->post('/bar', function ($req, $res, $args) {
  //Your amazing route code
});

$app->run();