vladzimir/f3-relay
Composer 安装命令:
composer require vladzimir/f3-relay
包简介
Simple middleware dispatcher for Fat-Free Framework
README 文档
README
Simple middleware relay and controller proxy hooks for Fat-Free Framework (F3).
- works with PHP 8.3+
- tested target: F3 3.9
Installation
- Method 1:
composer require vladzimir/f3-relay - Method 2: copy
lib/*into your projectlib/(or any F3 autoloaded path)
Quick start
use F3Relay\Relay; $relay = Relay::instance(); // Register middleware for key "web" $relay->pipe('web', [ static function () { // return false to stop chain return true; } ]); // Run chain $relay->run('web');
Conditional middleware (matchers)
Each pipe item may contain matchers first and middleware last.
use F3Relay\Relay; use F3Relay\Matchers\MatcherPath; use F3Relay\Matchers\MatcherHive; $relay = Relay::instance(); $relay->pipe('web', [ new MatcherPath('/admin/*'), new MatcherHive('VERB', 'GET'), static function () { // runs only if all matchers are true return true; } ], priority: 20);
Available matchers:
MatcherPath(pattern, flags = 0)MatcherHive(key, pattern)MatcherPattern(pattern, flags = 0, source = 'PATH')
Use ! prefix in pattern for negative match, e.g. !/api/*.
Controller hooks
ControllerProxy lets you install global before/after hooks for controllers resolved via F3 CONTAINER.
use F3Relay\ControllerProxy; ControllerProxy::install( before: static function (array $params, object $controller, ?array $args): bool { // return false to cancel route handling return true; }, after: static function (array $params, object $controller, ?array $args): void { // post-processing } );
Notes:
beforeruns before controllerbeforeroute()afterruns after controllerafterroute()- returning
falsefrom a hook stops further processing
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2026-05-16