The package provides current PSR-7 request as a dependency.
- PHP 8.1 or higher.
The package could be installed with composer:
composer require yiisoft/request-provider
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();
// ...
}
}
The package is tested with PHPUnit. To run tests:
./vendor/bin/phpunit
The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:
./vendor/bin/roave-infection-static-analysis-plugin
The code is statically analyzed with Psalm. To run static analysis:
./vendor/bin/psalm
Use Rector to make codebase follow some specific rules or use either newest or any specific version of PHP:
./vendor/bin/rector
Use ComposerRequireChecker to detect transitive Composer dependencies.
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.