MyGit

esbenp/onion

Fork: 21 Star: 72 (更新于 1970-01-01 00:00:00)

license: MIT

Language: PHP .

A before/after middleware implementation

最后发布版本: 1.0.0 ( 2017-01-10 11:45:54)

官方网址 GitHub网址

Onion

Build Status Coverage Status

A standalone middleware library without dependencies inspired by middleware in Laravel (Illuminate/Pipeline).

I have written a small blog post about the library and how to use it: Implementing before/after middleware in PHP

Installation

composer require optimus/onion ~1.0

Usage

class BeforeLayer implements LayerInterface {

    public function peel($object, Closure $next)
    {
        $object->runs[] = 'before';

        return $next($object);
    }

}

class AfterLayer implements LayerInterface {

    public function peel($object, Closure $next)
    {
        $response = $next($object);

        $object->runs[] = 'after';

        return $response;
    }

}

$object = new StdClass;
$object->runs = [];

$onion = new Onion;
$end = $onion->layer([
                new AfterLayer(),
                new BeforeLayer(),
                new AfterLayer(),
                new BeforeLayer()
            ])
            ->peel($object, function($object){
                $object->runs[] = 'core';
                return $object;
            });

var_dump($end);

Will output

..object(stdClass)#161 (1) {
  ["runs"]=>
  array(5) {
    [0]=>
    string(6) "before"
    [1]=>
    string(6) "before"
    [2]=>
    string(4) "core"
    [3]=>
    string(5) "after"
    [4]=>
    string(5) "after"
  }
}

最近版本更新:(数据更新于 1970-01-01 00:00:00)

2017-01-10 11:45:54 1.0.0

2015-07-16 18:19:17 0.1.0

esbenp/onion同语言 PHP最近更新仓库

2024-11-13 23:19:14 symfony/symfony

2024-11-13 22:53:21 symfony/var-dumper

2024-11-11 23:40:24 coollabsio/coolify

2024-11-06 20:45:55 schmittjoh/JMSSerializerBundle

2024-10-31 21:37:53 filamentphp/filament

2024-10-11 03:27:29 odan/slim4-skeleton