ray / http-message
PSR7 module for Ray.Di
Installs: 115 333
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^7.3 || ^8.0
- nyholm/psr7: ^1.0
- nyholm/psr7-server: ^1.0
- psr/http-message: ^1.0
- ray/aop: ^2.10.3
- ray/di: ^2.11
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4
- phpunit/phpunit: ^9.5
README
Overview
Ray.Psr7Module
provides RequestProvider
to get the PSR7 ServerRequest object.
Installation
Composer install
$ composer require ray/psr7-module
Module install
use Ray\Di\AbstractModule; use Ray\Psr7Module; class AppModule extends AbstractModule { protected function configure() { $this->install(new Psr7Module); } }
Usage
ServerRequest (general)
class Foo { public function __construct(ServerRequestInterface $serverRequest) { // retrieve cookies $cookie = $serverRequest->getCookieParams(); // $_COOKIE } }
URI
use Psr\Http\Message\UriInterface; class Foo { public function __construct(UriInterface $uri) { // retrieve host name $host = $uri->getHost(); } }
Upload Files
use Psr\Http\Message\UploadedFileInterface; use Ray\HttpMessage\Annotation\UploadFiles; class Foo { /** * @UploadFiles */ public function __construct(array $files) { // retrieve file name $file = $files['my-form']['details']['avatar'][0] /* @var UploadedFileInterface $file */ $name = $file->getClientFilename(); // my-avatar3.png } }