承接 jjanvier/yamo 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

jjanvier/yamo

Composer 安装命令:

composer require jjanvier/yamo

包简介

Yet another middleware orchestrator. A simple PSR-15 implementation.

README 文档

README

Build Status license

Yamo is yet another PSR-15 middleware orchestrator.

The purpose of this library is just to help discovering and understanding the PSR-15 about HTTP middlewares.

Usage

Just provide the list of the middlewares you want to use:

$orchestrator = new Orchestrator([
        // a list of Psr\Http\ServerMiddleware\MiddlewareInterface middlewares
    ]
);

$response = $orchestrator->process($request);

Please note that middlewares are called exactly in the order they are defined. For instance

$orchestrator = new Orchestrator([
        $middleware1,
        $middleware2,
        $middleware3,
    ]
);

$response = $orchestrator->process($request);

will lead to the following execution flow:

PSR-15 middlewares flow

Each middleware can, if needed, enrich the incoming request until it reaches the core application. The core application then processes the request to generate a response. This response is transmitted to each middleware which can also, if needed, enrich the response. Finally, when all middlewares have been reached, the orchestrator returns the final response.

Alternatively, you can also define the PSR-17 response factory factory you want to use. This factory will be used to return a default 200 response in case no middleware provided one. The default response factory is Http\Factory\Diactoros\ResponseFactory.

$customResponseFactory = new Http\Factory\Guzzle\ResponseFactory; // any Psr\Http\Message\ResponseFactoryInterface 
$orchestrator = new Orchestrator([
        // a list of Psr\Http\ServerMiddleware\MiddlewareInterface middlewares
    ], 
    $customResponseFactory
);

$response = $orchestrator->process($request);

Examples

For "academic" purpose, some middleware examples are provided in the examples folder. Those classes are not meant to be used. They can be considered as "advanced pseudo code" to help understand the reader. The example application can be launched with php -S 127.0.0.1:8080 -t examples/src/.

Real PSR-15 middlewares can be found in the middlewares/psr15-middlewares repository.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固