Final Class Yiisoft\Yii\Runner\Http\HttpApplicationRunner
| Inheritance | Yiisoft\Yii\Runner\Http\HttpApplicationRunner » Yiisoft\Yii\Runner\ApplicationRunner |
|---|
HttpApplicationRunner runs the Yii HTTP application.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Yii\Runner\Http\HttpApplicationRunner | |
| run() | Yiisoft\Yii\Runner\Http\HttpApplicationRunner | |
| runAndGetResponse() | Runs the application and gets the response instead of emitting it. | Yiisoft\Yii\Runner\Http\HttpApplicationRunner |
| withTemporaryErrorHandler() | Yiisoft\Yii\Runner\Http\HttpApplicationRunner |
Method Details
| public mixed __construct ( string $rootPath, boolean $debug = false, boolean $checkEvents = false, string|null $environment = null, string $bootstrapGroup = 'bootstrap-web', string $eventsGroup = 'events-web', string $diGroup = 'di-web', string $diProvidersGroup = 'di-providers-web', string $diDelegatesGroup = 'di-delegates-web', string $diTagsGroup = 'di-tags-web', string $paramsGroup = 'params-web', array $nestedParamsGroups = ['params'], array $nestedEventsGroups = ['events'], object[] $configModifiers = [], string $configDirectory = 'config', string $vendorDirectory = 'vendor', string $configMergePlanFile = '.merge-plan.php', \Psr\Log\LoggerInterface|null $logger = null, integer|null $bufferSize = null, \Yiisoft\ErrorHandler\ErrorHandler|null $temporaryErrorHandler = null, \Yiisoft\PsrEmitter\EmitterInterface|null $emitter = null, boolean $useRemoveBodyByStatusMiddleware = true, boolean $useContentLengthMiddleware = true, boolean $useHeadRequestMiddleware = true ) | ||
| $rootPath | string |
The absolute path to the project root. |
| $debug | boolean |
Whether the debug mode is enabled. |
| $checkEvents | boolean |
Whether to check events' configuration. |
| $environment | string|null |
The environment name. |
| $bootstrapGroup | string |
The bootstrap configuration group name. |
| $eventsGroup | string |
The events' configuration group name. |
| $diGroup | string |
The container definitions' configuration group name. |
| $diProvidersGroup | string |
The container providers' configuration group name. |
| $diDelegatesGroup | string |
The container delegates' configuration group name. |
| $diTagsGroup | string |
The container tags' configuration group name. |
| $paramsGroup | string |
The configuration parameters group name. |
| $nestedParamsGroups | array |
Configuration group names that are included into configuration parameters group. This is needed for recursive merging of parameters. |
| $nestedEventsGroups | array |
Configuration group names that are included into events' configuration group. This is needed for reverse and recursive merge of events' configurations. |
| $configModifiers | object[] |
Modifiers for {@see \Yiisoft\Yii\Runner\Http\Config}. |
| $configDirectory | string |
The relative path from {@see $rootPath} to the configuration storage location. |
| $vendorDirectory | string |
The relative path from {@see $rootPath} to the vendor directory. |
| $configMergePlanFile | string |
The relative path from {@see $configDirectory} to merge plan. |
| $logger | \Psr\Log\LoggerInterface|null |
(deprecated) The logger to collect errors while container is building. |
| $bufferSize | integer|null |
The size of the buffer in bytes to send the content of the message body. Deprecated and will be removed in the next major version. Use custom emitter instead. |
| $temporaryErrorHandler | \Yiisoft\ErrorHandler\ErrorHandler|null |
The temporary error handler instance that used to handle the creation of configuration and container instances, then the error handler configured in your application configuration will be used. |
| $emitter | \Yiisoft\PsrEmitter\EmitterInterface|null |
The emitter instance to send the response with. By default, it uses {@see \Yiisoft\PsrEmitter\SapiEmitter}. |
| $useRemoveBodyByStatusMiddleware | boolean |
Whether to remove the body of the response for specific response
status codes. Deprecated and will be removed in the next major version. Use |
| $useContentLengthMiddleware | boolean |
Whether to manage the |
| $useHeadRequestMiddleware | boolean |
Whether to remove the body of the response for HEAD requests. Deprecated
and will be removed in the next major version. Use |
public function __construct(
string $rootPath,
bool $debug = false,
bool $checkEvents = false,
?string $environment = null,
string $bootstrapGroup = 'bootstrap-web',
string $eventsGroup = 'events-web',
string $diGroup = 'di-web',
string $diProvidersGroup = 'di-providers-web',
string $diDelegatesGroup = 'di-delegates-web',
string $diTagsGroup = 'di-tags-web',
string $paramsGroup = 'params-web',
array $nestedParamsGroups = ['params'],
array $nestedEventsGroups = ['events'],
array $configModifiers = [],
string $configDirectory = 'config',
string $vendorDirectory = 'vendor',
string $configMergePlanFile = '.merge-plan.php',
private readonly ?LoggerInterface $logger = null,
?int $bufferSize = null,
private ?ErrorHandler $temporaryErrorHandler = null,
?EmitterInterface $emitter = null,
private readonly bool $useRemoveBodyByStatusMiddleware = true,
private readonly bool $useContentLengthMiddleware = true,
private readonly bool $useHeadRequestMiddleware = true,
) {
$this->emitter = $emitter ?? new SapiEmitter($bufferSize);
parent::__construct(
$rootPath,
$debug,
$checkEvents,
$environment,
$bootstrapGroup,
$eventsGroup,
$diGroup,
$diProvidersGroup,
$diDelegatesGroup,
$diTagsGroup,
$paramsGroup,
$nestedParamsGroups,
$nestedEventsGroups,
$configModifiers,
$configDirectory,
$vendorDirectory,
$configMergePlanFile,
);
}
| public void run ( ) | ||
| throws | \Yiisoft\Definitions\Exception\CircularReferenceException|ErrorException|Yiisoft\Yii\Runner\Http\Exception\HeadersHaveBeenSentException|\Yiisoft\Definitions\Exception\InvalidConfigException | |
|---|---|---|
| throws | \Psr\Container\ContainerExceptionInterface|\Yiisoft\Di\NotFoundException|\Psr\Container\NotFoundExceptionInterface|\Yiisoft\Definitions\Exception\NotInstantiableException | |
public function run(): void
{
$this->runInternal($this->emitter);
}
Runs the application and gets the response instead of emitting it.
This method is useful for testing purposes or when you want to handle the response.
| public \Psr\Http\Message\ResponseInterface runAndGetResponse ( \Psr\Http\Message\ServerRequestInterface|null $request = null ) | ||
| $request | \Psr\Http\Message\ServerRequestInterface|null |
The server request to handle (optional). |
| return | \Psr\Http\Message\ResponseInterface |
The response generated by the application. |
|---|---|---|
| throws | \Yiisoft\Definitions\Exception\CircularReferenceException|ErrorException|Yiisoft\Yii\Runner\Http\Exception\HeadersHaveBeenSentException|\Yiisoft\Definitions\Exception\InvalidConfigException | |
| throws | \Psr\Container\ContainerExceptionInterface|\Yiisoft\Di\NotFoundException|\Psr\Container\NotFoundExceptionInterface|\Yiisoft\Definitions\Exception\NotInstantiableException | |
public function runAndGetResponse(?ServerRequestInterface $request = null): ResponseInterface
{
$this->runInternal(
$this->fakeEmitter ??= new FakeEmitter(),
$request,
);
return $this->fakeEmitter->getLastResponse()
?? throw new LogicException('No response was emitted.');
}
$temporaryErrorHandler constructor parameter instead.
Returns a new instance with the specified temporary error handler instance {@see \Yiisoft\ErrorHandler\ErrorHandler}.
A temporary error handler is needed to handle the creation of configuration and container instances,
then the error handler configured in your application configuration will be used.
| public self withTemporaryErrorHandler ( \Yiisoft\ErrorHandler\ErrorHandler $temporaryErrorHandler ) | ||
| $temporaryErrorHandler | \Yiisoft\ErrorHandler\ErrorHandler |
The temporary error handler instance. |
public function withTemporaryErrorHandler(ErrorHandler $temporaryErrorHandler): self
{
$new = clone $this;
$new->temporaryErrorHandler = $temporaryErrorHandler;
return $new;
}
Signup or Login in order to comment.