https://github.com/thecodingmachine/symfony-psr15-bridge
A bridge between Symfony middlewares (StackPHP) and http-interop middlewares for converting Symfony Http abstractions to PSR-15 and back.
https://github.com/thecodingmachine/symfony-psr15-bridge
Last synced: 11 months ago
JSON representation
A bridge between Symfony middlewares (StackPHP) and http-interop middlewares for converting Symfony Http abstractions to PSR-15 and back.
- Host: GitHub
- URL: https://github.com/thecodingmachine/symfony-psr15-bridge
- Owner: thecodingmachine
- License: mit
- Created: 2016-11-23T15:40:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-06-22T23:28:34.000Z (over 4 years ago)
- Last Synced: 2025-04-11T18:59:51.421Z (11 months ago)
- Language: PHP
- Size: 22.5 KB
- Stars: 16
- Watchers: 10
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# thecodingmachine/symfony-psr15-bridge
Bridges between [Symfony HttpKernel](http://symfony.com/doc/current/components/http_kernel/introduction.html) (a.k.a. [StackPHP Middleware](http://stackphp.com/)) and [PSR-15 middlewares](https://www.php-fig.org/psr/psr-15/).
[](https://packagist.org/packages/thecodingmachine/symfony-psr15-bridge)
[](https://packagist.org/packages/thecodingmachine/symfony-psr15-bridge)
[](https://packagist.org/packages/thecodingmachine/symfony-psr15-bridge)
[](https://packagist.org/packages/thecodingmachine/symfony-psr15-bridge)
[](https://scrutinizer-ci.com/g/thecodingmachine/symfony-psr15-bridge/?branch=master)
[](https://travis-ci.org/thecodingmachine/symfony-psr15-bridge)
[](https://coveralls.io/github/thecodingmachine/symfony-psr15-bridge?branch=master)
Those adapters are built on top of the existing [symfony/psr-http-message-bridge](https://github.com/symfony/psr-http-message-bridge) that bridges Symfony and PSR-7 HTTP messages.
## Installation
The recommended way to install symfony-psr15-bridge is through [Composer](http://getcomposer.org/):
```sh
composer require thecodingmachine/symfony-psr15-bridge
```
## Usage
By default, the Symfony HttpFoundation and HttpKernel are used.
For PSR-7, the [Zend-Diactoros](https://github.com/zendframework/zend-diactoros) implementation is used.
These implementations can be changed if needed.
### Wrapping a HttpKernel
```php
process($psr7Request, $dummyNextPsr7Middleware);
```
**Important:** Symfony Http Kernels do not have the notion of "next" middlewares. Therefore, the "next" PSR-7 middleware
you pass to the `process` method will never be called.
### Wrapping a PSR-7 callback
```php
handle($symfonyRequest);
```
Note: the adapter's constructor takes 2 middlewares: the "next" Symfony middleware that will be called by the "delegate"
psr15 feature and the psr15 middleware to be wrapped.
## Other known middleware adapters
I initially planned to submit this project as a PR to [h4cc/stack-psr7-bridge](https://github.com/h4cc/stack-psr7-bridge/) (that was developed before the notion of "PSR-7 middleware" was standardized in http-interop that was itself the precursor to PSR-15).
I soon realized that this was in fact a complete rewrite so I decided to create a new project for it.