PSR7

An existing BEAR.Sunday application can work as a PSR7 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 127.0.0.1:8080 -t var/www

Stream

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.

public function onGet($name = 'BEAR.Sunday')
{
    $fp = fopen(__DIR__ . '/image.jpg', 'r');
    stream_filter_append($fp, 'convert.base64-encode');
    $this['greeting'] = 'Hello ' . $name;
    $this['image'] = $fp; // image in base64 format

    return $this;
}

New Project

You can create a BEAR.Sunday PSR7 project with bear/project.

composer create-project bear/project my-awesome-project
cd my-awesome-project/
php -S 127.0.0.1:8080 -t var/www/

And you can add other middlewares or Ray.Di modules as you need from these sources: