yiisoft/request-provider

PSR-7 request provider

Maintainers

👁 samdark
👁 vjik

Package info

github.com/yiisoft/request-provider

Homepage

Chat

Forum

Wiki

pkg:composer/yiisoft/request-provider

Fund package maintenance!

Opencollective

yiisoft

Statistics

Installs: 98 664

Dependents: 15

Suggesters: 1

Stars: 9

Open Issues: 3

1.3.0 2026-01-29 14:03 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause 6676b0e4d213fc987f01bcede8053b2be4ce2c63

httpproviderrequestpsryii3

This package is auto-updated.

Last update: 2026-06-24 21:45:46 UTC


README

👁 Yii

Yii Request Provider


👁 Latest Stable Version
👁 Total Downloads
👁 Build status
👁 Code Coverage
👁 Mutation testing badge
👁 Static analysis
👁 type-coverage
👁 psalm-level

The package provides the current PSR-7 request as a dependency.

Requirements

  • PHP 8.1 - 8.5.

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

👁 Open Collective

Follow updates

👁 Official website
👁 Twitter
👁 Telegram
👁 Facebook
👁 Slack