0 follower

Final Class Yiisoft\Yii\Runner\Http\HttpApplicationRunner

InheritanceYiisoft\Yii\Runner\Http\HttpApplicationRunner » Yiisoft\Yii\Runner\ApplicationRunner

HttpApplicationRunner runs the Yii HTTP application.

Method Details

Hide inherited methods

__construct() public method

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 RemoveBodyMiddleware from {@see https://github.com/yiisoft/http-middleware/} instead.

$useContentLengthMiddleware boolean

Whether to manage the Content-Length header to the response. Deprecated and will be removed in the next major version. Use ContentLengthMiddleware from {@see https://github.com/yiisoft/http-middleware/} instead.

$useHeadRequestMiddleware boolean

Whether to remove the body of the response for HEAD requests. Deprecated and will be removed in the next major version. Use HeadRequestMiddleware from {@see https://github.com/yiisoft/http-middleware/} instead.

                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,
    );
}

            
run() public method

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);
}

            
runAndGetResponse() public method

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

            
withTemporaryErrorHandler() public method
Deprecated Use $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;
}