2017 © Pedro Peláez
 

library easy-pipeline

An easy pipeline, learn Laravel.

image

yjx/easy-pipeline

An easy pipeline, learn Laravel.

  • Monday, May 28, 2018
  • by youjiaxing
  • Repository
  • 0 Watchers
  • 1 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

EasyPipeline

一个简单管道的实现, 参考Laravel的管道实现., (*1)

本项目创建的目的在于个人理解管道设计模式, 同时想要有一个不依赖于任何框架的管道实现., (*2)

使用

(new EasyPipeline\Pipeline())->send($passable)->through($pipes)->then($lastPipe);, (*3)

若将管道用于web请求的中间件组合, (*4)

$response = (new EasyPipeline\Pipeline())
    ->send($request)
    ->through($middlewares)
    ->then($dispatch);

中间件的定义方式

$middlewares = [
    VerifyCsrfToken::class, // 类名

    [ThrottleRequests::class, [60, 1]], // 数组形式: 类名 + 数组参数

    ThrottleRequests::class."?60:1",    // 字符串形式: 类名 + 参数

    "throttle?60:1",    // 字符串别名形式: 管理实例化时需传入容器实例

    function ($request, \Closure $next) {   // 闭包
        //...
        return $next($request);
    },
];

使用非闭包方式定义的中间件时, 需注入容器(实现ContainerInterface)以便Pipeline实例化中间件., (*5)

若指定某个类, 则该类需实现 'handle'方法 或 '__invoke'方法., (*6)

The Versions

28/05 2018

dev-master

9999999-dev

An easy pipeline, learn Laravel.

  Sources   Download

MIT

The Requires

 

by Avatar youjiaxing

28/05 2018

v1.0.1

1.0.1.0

An easy pipeline, learn Laravel.

  Sources   Download

MIT

The Requires

 

by Avatar youjiaxing

28/05 2018

v1.0.0

1.0.0.0

An easy pipeline, learn Laravel.

  Sources   Download

MIT

The Requires

 

by Avatar youjiaxing