yiisoft/request-provider
最新稳定版本:1.2.0
Composer 安装命令:
composer require yiisoft/request-provider
包简介
PSR-7 request provider
关键字:
README 文档
README
Yii Request Provider
The package provides the current PSR-7 request as a dependency.
Requirements
- PHP 8.1 or higher.
Installation
The package can be installed with Composer:
composer require yiisoft/request-provider
General usage
First, add the Yiisoft\RequestProvider\RequestCatcherMiddleware to your application middleware stack.
Then, when you need the current request, get the RequestProviderInterface as a dependency and obtain the request from it:
use Yiisoft\RequestProvider\RequestProviderInterface; final class MyService { public function __construct( private readonly RequestProviderInterface $requestProvider ) { } public function doIt() { $request = $this->requestProvider->get(); // ... } }
Request cookies provider
You can work with cookies as follows:
class MyClass { public function __construct( private \Yiisoft\RequestProvider\RequestCookieProvider $cookies ) {} public function go(): void { $this->cookies->has('foo'); $this->cookies->get('bar'); } }
Request headers provider
You can work with headers as follows:
class MyClass { public function __construct( private \Yiisoft\RequestProvider\RequestHeaderProvider $headers ) {} public function go(): void { $this->headers->has('X-Foo'); $this->headers->get('X-Foo'); $this->headers->getLine('X-Foo'); $this->headers->getAll(); $this->headers->getFirstHeaders(); } }
Documentation
If you need help or have a question, the Yii Forum is a helpful resource. You may also check out other resources at Yii Community Resources.
License
The Yii Request Provider is free software. It is released under the terms of the BSD License.
Please see LICENSE for more information.
Maintained by Yii Software.
Support the project
Follow updates
统计信息
- 总下载量: 53.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2024-02-29