定制 vladzimir/f3-relay 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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 project lib/ (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:

  • before runs before controller beforeroute()
  • after runs after controller afterroute()
  • returning false from a hook stops further processing

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2026-05-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固