request-provider

Provides current PSR-7 request as a dependency.

BSD-3-CLAUSE License

Downloads
12.6K
Stars
5
Committers
5

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

Requirements

  • PHP 8.1 or higher.

Installation

The package could be installed with Composer:

composer require yiisoft/request-provider

General usage

First, add Yiisoft\RequestProvider\RequestCatcherMiddleware to your application middleware stack.

Then, when you need current request, get RequestProviderInterface as 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();
        // ...
    }
}

Documentation

If you need help or have a question, the Yii Forum is a good place for that. You may also check out other 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