juicelib/filtermodule
Composer 安装命令:
composer require juicelib/filtermodule
包简介
Intercept requests/responses at the route/MvcEvent::EVENT_ROUTE event and transform or use the request or response
README 文档
README
Intercept requests/responses at the route/MvcEvent::EVENT_ROUTE event and transform or use the request or response.
Usage
Include the JuiceLib\FilterModule in application.config.php
'modules' => array(
'JuiceLib\FilterModule',
// your other modules
),
Create a juice.global.php file inside config/autoload. Alternatively you could add the filter config in any of your module's module.config.php
<?php
// juice.global.php
return array(
'juice' => array(
'filter' => array(
'FilterProtection' => array(
'/protected/(.*)',
),
),
'filter_mapping' => array(
'FilterProtection' => 'Protected\Filter\Namespace\MyFilter',
),
),
);
Create your filter class, in this case I'll call it MyFilter.php this has to match the filter mapping in the configuration.
<?php
namespace Protected\Filter\Namespace;
use JuiceLib\FilterModule\Filter\FilterInterface;
use Zend\Http\Request as HttpRequest;
use Zend\Http\Response as HttpResponse;
use Zend\Mvc\Application;
class MyFilter implements FilterInterface {
public function processFilter(HttpRequest &$request, HttpResponse &$response, Application &$application)
{
/** @var \Zend\Http\Header\HeaderInterface $authKeyHeader */
$authKeyHeader = $request->getHeader('my-auth-key');
if (!$authKeyHeader || $authKeyHeader->getFieldValue() != 'secret-password') {
$response->setStatusCode(401);
return $response;
}
}
}
In the previous example we are protected any path that starts with /protected/ by checking the my-auth-key header. This can also be used with sessions or other methods of authentication.
Additionally this can be used to add you own response headers for each response sent from the application that matches the filter's path.
juicelib/filtermodule 适用场景与选型建议
juicelib/filtermodule 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 03 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「zf2」 「filter」 「Zend Framework」 「zend framework 2」 「request filter」 「response filter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 juicelib/filtermodule 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 juicelib/filtermodule 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 juicelib/filtermodule 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LosLog provides some log utility
Nova searchable filter for belongsTo relationships.
EdpModuleLayouts is very simple Laminas module for making module-specific layouts insanely easy.
Symfony DataGridBundle
Polyfill for mb_ereg(), mb_eregi(), mb_ereg_match(), and mb_ereg_replace*() functions; primary use case is for mbstring on Windows 7.4+
Zend Framework module to leverage the symfony dependency injection container
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-23