1. Go to this page and download the library: Download alsar/stack-ip-restrict 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/ */
alsar / stack-ip-restrict example snippets
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Alsar\Stack\IpRestrict;
$app = new Silex\Application();
$app->get('/', function(Request $request) {
return new Response('Hello world!', 200);
});
$app = (new Stack\Builder())
->push('Alsar\Stack\IpRestrict', ['127.0.0.1'])
->resolve($app)
;
$request = Request::createFromGlobals();
$response = $app->handle($request)->send();
$app->terminate($request, $response);
# web/app_dev.php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
$loader = ->loadClassCache();
$stack = (new Stack\Builder())
->push('Alsar\Stack\IpRestrict', ['127.0.0.1', 'fe80::1', '::1']);
$kernel = $stack->resolve($kernel);
Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.