JS>> mw>> 返回
项目作者: krakphp

项目描述 :
Framework Agnostic Middleware Library
高级语言: PHP
项目地址: git://github.com/krakphp/mw.git
创建时间: 2016-06-13T03:25:53Z
项目社区:https://github.com/krakphp/mw

开源协议:MIT License

下载


Mw (Middleware)

Author
Source Code
Latest Version
Software License
Documentation Status
Total Downloads

The Mw library is a very flexible framework for converting middleware into handlers. Middleware offer a clean syntax for implementing the Decorator Pattern

  1. <?php
  2. use Krak\Mw;
  3. $handler = mw\compose([
  4. function($s, $next) {
  5. return strtoupper($s);
  6. },
  7. function($s, $next) {
  8. return 'x' . $next($s . 'x');
  9. }
  10. ]);
  11. $res = $handler('abc');
  12. assert($res == 'xABCX');

Installation

You can install this as a composer package at krak/mw

Documentation

View them at http://mw.readthedocs.io/en/latest/

Or build them:

  1. make doc

Tests and Examples

Run tests via:

  1. make test

The Mw library uses Peridot. These tests also provide good examples of how to use the library.