PHP code example of amonger / firewall
1. Go to this page and download the library: Download amonger/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/ */
amonger / firewall example snippets
use \amonger\Firewall\Firewall;
$firewall = new Firewall($_SERVER['REQUEST_URI']);
$firewall
->route('/managers\/.*/')
->unless(function ($uri) use ($container) {
return $container['auth']->hasRole('manager');
})
->handle(function () {
throw new _401Exception();
})
->execute();
use \amonger\Firewall\Firewall;
$firewall = Firewall::getBuilder();
$firewall->setRequestUri($_SERVER['REQUEST_URI']);
$firewall
->route('/managers\/.*/')
->unless(function ($uri) use ($container) {
return $container['auth']->hasRole('manager');
})
->handle(function () {
throw new _401Exception();
});
$firewall
->route('/clients\/.*/')
->unless(function ($uri) use ($container) {
return $container['auth']->hasRole('clients');
})
->handle(function () {
throw new _401Exception();
});
Firewall::run($firewall);