Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/razonyang/psr7-swoole
The PSR7 helpers for Swoole.
https://github.com/razonyang/psr7-swoole
psr-7 psr7 swoole
Last synced: 2 months ago
JSON representation
The PSR7 helpers for Swoole.
- Host: GitHub
- URL: https://github.com/razonyang/psr7-swoole
- Owner: razonyang
- License: mit
- Created: 2022-09-16T16:43:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-24T08:42:55.000Z (over 2 years ago)
- Last Synced: 2024-05-22T13:35:08.295Z (8 months ago)
- Topics: psr-7, psr7, swoole
- Language: PHP
- Homepage:
- Size: 23.4 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-swoole - razonyang/psr7-swoole - A PSR-7 helper for Swoole; a bridge between Swoole and PSR things, such as PSR-7 HTTP message, PSR-15 handlers and PSR-15 middlewares. (HTTP and WebSocket)
README
# Swoole + PSR7
[![Latest Stable Version](https://poser.pugx.org/razonyang/psr7-swoole/v/stable.png)](https://packagist.org/packages/razonyang/psr7-swoole)
[![Total Downloads](https://poser.pugx.org/razonyang/psr7-swoole/downloads.png)](https://packagist.org/packages/razonyang/psr7-swoole)
[![Build Status](https://github.com/razonyang/psr7-swoole/workflows/build/badge.svg)](https://github.com/razonyang/psr7-swoole/actions)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/razonyang/psr7-swoole/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/razonyang/psr7-swoole/?branch=main)
[![Code Coverage](https://scrutinizer-ci.com/g/razonyang/psr7-swoole/badges/coverage.png?b=main)](https://scrutinizer-ci.com/g/razonyang/psr7-swoole/?branch=main)
[![StyleCI](https://github.styleci.io/repos/537541555/shield?branch=main)](https://github.styleci.io/repos/537541555?branch=main)The PSR-7 helpers for Swoole, the bridge of Swoole and PSR things, such as PSR-7 HTTP message, PSR-15 handlers and PSR-15 middlewares.
It allows to integrate Swoole with PSR-compatible frameworks to speed up your applications.- Convert `Swoole\Http\Request` to `Psr\Http\Message\ServerRequestInterface`.
- Emit `Psr\Http\Message\ResponseInterface` to `Swoole\Http\Response`.## Installation
```bash
composer require razonyang/psr7-swoole --prefer-dist
```## Usage
```php
handle('/', function ($request, $response) use ($emitterFactory, $serverRequestFactory, $psr7Factory) {
$emitter = $emitterFactory->create($response);
$psrRequest = $serverRequestFactory->create($request);
$psrResponse = $psr7Factory
->createResponse(200)
->withBody(Stream::create($psrRequest->getUri()->getPath()));
$emitter->emit($psrResponse);
});$server->start();
});
```