An existing BEAR.Sunday application can work as a PSR-7 middleware with these easy steps:

1) Add bear/middleware package then replace bootstrap.php script.

composer require bear/middleware
cp vendor/bear/middleware/bootstrap/bootstrap.php bootstrap/bootstrap.php

2) Replace __PACKAGE__\__VENDOR__ in bootstrap.php to application namespace.

Stat the server.

php -S -t public


BEAR.Sunday supports HTTP body of a message output in a stream.

In ResourceObject, you can mix stream with a normal string. The output is converted to a single stream. StreamTransfer is the default HTTP transfer. Seem more at Stream Response.

New Project

You can also create a BEAR.Sunday PSR-7 project with bear/project from scratch.

composer create-project bear/project my-psr7-project
cd my-psr7-project/
php -S -t public

PSR-7 middleware