2024-03-02 321次浏览

First stable release of yiisoft/request-provider was tagged.

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

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();
        // ...
    }
}