PHPackages                             cormy/bamboo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. cormy/bamboo

ActiveLibrary[HTTP &amp; Networking](/categories/http)

cormy/bamboo
============

Bamboo style PSR-7 middleware pipe using generators

0.1.1(9y ago)118MITPHPPHP &gt;=7

Since Nov 22Pushed 9y ago1 watchersCompare

[ Source](https://github.com/cormy/bamboo)[ Packagist](https://packagist.org/packages/cormy/bamboo)[ RSS](/packages/cormy-bamboo/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

Cormy Bamboo [![Build Status](https://camo.githubusercontent.com/987392dee6b289a295102b09b3348c259164b3702ba0ab1a6d3237810f9ab51f/68747470733a2f2f7472617669732d63692e6f72672f636f726d792f62616d626f6f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cormy/bamboo) [![Coverage Status](https://camo.githubusercontent.com/e9bb73ffbbf20e1b6c9289b9b1073d18907fc5878c9d1f3e63df8f6915027fde/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f636f726d792f62616d626f6f2f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/cormy/bamboo?branch=master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/b0657fa96dd979397b1177e4ba41f73114071d53805b2faedc5520807c948920/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f726d792f62616d626f6f2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/cormy/bamboo/?branch=master)
===================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#cormy-bamboo---)

[![SensioLabsInsight](https://camo.githubusercontent.com/c65b5439459951b4d60988ae9c79906cdee44aa1c4046b71697e87e524a7476f/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35346631303939612d336666302d343332382d383336642d6538303433386165373564632f6269672e706e67)](https://insight.sensiolabs.com/projects/54f1099a-3ff0-4328-836d-e80438ae75dc)

> 🎍 Bamboo style [PSR-7](http://www.php-fig.org/psr/psr-7) **middleware pipe** using generators

Install
-------

[](#install)

```
composer require cormy/bamboo

```

Usage
-----

[](#usage)

```
use Cormy\Server\Bamboo;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

// create your bamboo stem nodes, aka middlewares
$nodes = [];

$nodes[] = function (ServerRequestInterface $request):\Generator {
    // delegate $request to the next request handler, i.e. the middleware right below
    $response = (yield $request);

    return $response->withHeader('X-PoweredBy', 'Unicorns');
};

$nodes[] = function (ServerRequestInterface $request):\Generator {
    // delegate $request to the next request handler, i.e. the $finalHandler below
    $response = (yield $request);

    return $response->withHeader('content-type', 'application/json; charset=utf-8');
};

// create the middleware pipe
$middlewarePipe = new Bamboo($nodes);

// create a handler for requests which reached the end of the pipe
$finalHandler = function (ServerRequestInterface $request):ResponseInterface {
    return new \Zend\Diactoros\Response();
};

// and dispatch a request
$response = $middlewarePipe->dispatch(new \Zend\Diactoros\ServerRequest(), $finalHandler);
```

API
---

[](#api)

### `Cormy\Server\Bamboo implements MiddlewareInterface`

[](#cormyserverbamboo-implements-middlewareinterface)

#### `Bamboo::__construct`

[](#bamboo__construct)

```
/**
 * Bamboo style PSR-7 middleware pipe.
 *
 * @param (callable|MiddlewareInterface)[] $nodes the middlewares, which requests pass through
 */
public function __construct(array $nodes)
```

#### `Bamboo::dispatch`

[](#bamboodispatch)

```
/**
 * Process an incoming server request and return the response.
 *
 * @param ServerRequestInterface           $request
 * @param callable|RequestHandlerInterface $finalHandler
 *
 * @return ResponseInterface
 */
public function dispatch(ServerRequestInterface $request, callable $finalHandler):ResponseInterface
```

#### Inherited from [`MiddlewareInterface::__invoke`](https://github.com/cormy/server-middleware)

[](#inherited-from-middlewareinterface__invoke)

```
/**
 * Process an incoming server request and return the response, optionally delegating
 * to the next request handler.
 *
 * @param ServerRequestInterface $request
 *
 * @return Generator yields PSR `ServerRequestInterface` instances and returns a PSR `ResponseInterface` instance
 */
public function __invoke(ServerRequestInterface $request):Generator;
```

Related
-------

[](#related)

- [Cormy\\Server\\Onion](https://github.com/cormy/onion) – Onion style PSR-7 **middleware stack** using generators
- [Cormy\\Server\\MiddlewareDispatcher](https://github.com/cormy/cormy/server-middleware-dispatcher) – Cormy PSR-7 server **middleware dispatcher**
- [Cormy\\Server\\RequestHandlerInterface](https://github.com/cormy/server-request-handler) – Common interfaces for PSR-7 server request handlers
- [Cormy\\Server\\MiddlewareInterface](https://github.com/cormy/server-middleware) – Common interfaces for Cormy PSR-7 server middlewares

License
-------

[](#license)

MIT © [Michael Mayer](http://schnittstabil.de)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3456d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6059032?v=4)[Michael Mayer](/maintainers/schnittstabil)[@schnittstabil](https://github.com/schnittstabil)

---

Top Contributors

[![schnittstabil](https://avatars.githubusercontent.com/u/6059032?v=4)](https://github.com/schnittstabil "schnittstabil (3 commits)")

---

Tags

httpresponserequestpsrpsr-7http-messagemiddlewarebamboopipecormy

### Embed Badge

![Health badge](/badges/cormy-bamboo/health.svg)

```
[![Health](https://phpackages.com/badges/cormy-bamboo/health.svg)](https://phpackages.com/packages/cormy-bamboo)
```

###  Alternatives

[psr/http-message

Common interface for HTTP messages

7.1k1.0B5.5k](/packages/psr-http-message)[psr/http-server-middleware

Common interface for HTTP server-side middleware

18091.2M1.5k](/packages/psr-http-server-middleware)[fig/http-message-util

Utility classes and constants for use with PSR-7 (psr/http-message)

39489.0M274](/packages/fig-http-message-util)[idealo/php-middleware-stack

Implementation of HTTP Middleware PSR-15 specification

318.9k](/packages/idealo-php-middleware-stack)[art4/requests-psr18-adapter

Use WordPress/Requests as a PSR-18 HTTP client

153.3k](/packages/art4-requests-psr18-adapter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
