PHPackages                             yoozoo/yii2-psr7-bridge - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. yoozoo/yii2-psr7-bridge

AbandonedArchivedLibrary[PSR &amp; Standards](/categories/psr-standards)

yoozoo/yii2-psr7-bridge
=======================

A PSR7 Bridge for Yii2

0.0.2(6y ago)2141BSD-3-ClausePHP

Since May 6Pushed 6y ago3 watchersCompare

[ Source](https://github.com/yoozoo/yii2-psr7-bridge)[ Packagist](https://packagist.org/packages/yoozoo/yii2-psr7-bridge)[ RSS](/packages/yoozoo-yii2-psr7-bridge/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (9)Versions (3)Used By (0)

Yii2 PSR-7 Bridge
=================

[](#yii2-psr-7-bridge)

A PSR-7 bridge and PSR-15 adapter for Yii2 web applications.

The usecase for this bridge is to enable Yii2 to be utilized with PSR-7 and PSR-15 middlewars and task runners such as RoadRunner and PHP-PM, with *minimal* code changes to your application (eg requiring no changes to any calls to `Yii::$app->request` and `Yii::$app->response` within your application).

> Note that this is currently very alpha quality. It "works" in that a PSR7 request is accepted as input and it returns a valid PSR7 response that is *mostly* in line with what you would expect.

> However, features and functionality are missing. Many things don't work, others have unexpectes side-effects. You are advised *not* to use this package at this time.

> See the `Current Status` checklist at the bottom of the README file for what is current implemented and what we could use help with.

What to help out?
-----------------

[](#what-to-help-out)

Contributors are welcome! Check out the `Current Status` checklist for things that still need to be implemented, help add tests, or add new features!

Installation
------------

[](#installation)

This package can be installed via Composer:

```
composer require charlesportwoodii/yii2-psr7-bridge

```

Tests
-----

[](#tests)

Tests can be run with `phpunit`.

```
./vendor/bin/phpunit
```

Usage
-----

[](#usage)

Due to the nature of this package, several changes are needed to your application.

### Dispatcher

[](#dispatcher)

1. Modify your `request` and `response` components within your web application config to be instance of `yii\Psr7\web\Request` and `yii\Psr7\web\Response`, respectively:

```
return [
    // Other flags
    'components' => [
        'request' => [
            'class' => \yii\Psr7\web\Request::class,
        ],
        'response' => [
            'class' => \yii\Psr7\web\Response::class
        ],
        // Other components
    ]
];
```

> If you're using a custom `Request` class, simply have it overload `yii\Psr7\web\Request` to inherit the base functionality.

2. Set the following environment variables to your task runner. With RoadRunner, your configuration might look as follows:

```
env:
  YII_ALIAS_WEBROOT: /path/to/webroot
  YII_ALIAS_WEB: '127.0.0.1:8080'
```

> All environment variables *must* be defined.

3. Run your application with a PSR-15 compatible dispatcher.

For example, to Go/Roadrunner, you can use the component as follows:

```
#!/usr/bin/env php
