amonger/firewall
最新稳定版本:v0.4.1
Composer 安装命令:
composer require amonger/firewall
包简介
README 文档
README
Firewall
This is a simple library which will have some action on a route being matched.
It is useful for legacy projects where some authorisation code my be copy pasted into a header multiple times and there is no under-laying structure.
Example
###Individual routes### You can define routes individually by doing the following:
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();
###Multiple routes### A scenario which is more likely is that you will have a single request uri and multiple routes you'd like to handle. In this case you can use the builder to setup the firewall.
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);
统计信息
- 总下载量: 382
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-31