0 follower

Final Class Yiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpApplicationRunner

InheritanceYiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpApplicationRunner » Yiisoft\Yii\Runner\ApplicationRunner

RoadRunnerHttpApplicationRunner runs the Yii HTTP application using RoadRunner.

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpApplicationRunner
run() Yiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpApplicationRunner
withPsr7Worker() Returns a new instance with the specified PSR-7 worker instance {@see PSR7WorkerInterface}. Yiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpApplicationRunner
withTemporalEnabled() Returns a new instance with enabled temporal support. Yiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpApplicationRunner
withTemporaryErrorHandler() Returns a new instance with the specified temporary error handler instance {@see ErrorHandler}. Yiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpApplicationRunner

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'] )
$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.

                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'],
) {
    parent::__construct(
        $rootPath,
        $debug,
        $checkEvents,
        $environment,
        $bootstrapGroup,
        $eventsGroup,
        $diGroup,
        $diProvidersGroup,
        $diDelegatesGroup,
        $diTagsGroup,
        $paramsGroup,
        $nestedParamsGroups,
        $nestedEventsGroups,
    );
}

            
run() public method

public run ( )
throws \Yiisoft\Definitions\Exception\CircularReferenceException|ErrorException|\Yiisoft\Definitions\Exception\InvalidConfigException|JsonException
throws \Psr\Container\ContainerExceptionInterface|\Yiisoft\Di\NotFoundException|\Psr\Container\NotFoundExceptionInterface|\Yiisoft\Definitions\Exception\NotInstantiableException

                public function run(): void
{
    // Register temporary error handler to catch error while container is building.
    $temporaryErrorHandler = $this->createTemporaryErrorHandler();
    $this->registerErrorHandler($temporaryErrorHandler);
    $container = $this->getContainer();
    // Register error handler with real container-configured dependencies.
    /** @var ErrorHandler $actualErrorHandler */
    $actualErrorHandler = $container->get(ErrorHandler::class);
    $this->registerErrorHandler($actualErrorHandler, $temporaryErrorHandler);
    $this->runBootstrap();
    $this->checkEvents();
    $env = Environment::fromGlobals();
    if ($env->getMode() === Mode::MODE_TEMPORAL) {
        if (!$this->isTemporalEnabled) {
            throw new RuntimeException(
                'Temporal support is disabled. You should call `withTemporalEnabled(true)` to enable temporal support.',
            );
        }
        $this->runTemporal($container);
        return;
    }
    if ($env->getMode() === Mode::MODE_HTTP) {
        $this->runRoadRunner($container);
        return;
    }
    throw new RuntimeException(sprintf(
        'Unsupported mode "%s", supported modes are: "%s".',
        $env->getMode(),
        implode('", "', [Mode::MODE_HTTP, Mode::MODE_TEMPORAL]),
    ));
}

            
withPsr7Worker() public method

Returns a new instance with the specified PSR-7 worker instance {@see PSR7WorkerInterface}.

public self withPsr7Worker ( \Spiral\RoadRunner\Http\PSR7WorkerInterface $worker )
$worker \Spiral\RoadRunner\Http\PSR7WorkerInterface

The PSR-7 worker instance.

                public function withPsr7Worker(PSR7WorkerInterface $worker): self
{
    $new = clone $this;
    $new->psr7Worker = $worker;
    return $new;
}

            
withTemporalEnabled() public method

Returns a new instance with enabled temporal support.

public self withTemporalEnabled ( boolean $value )
$value boolean

                public function withTemporalEnabled(bool $value): self
{
    if (!$this->isTemporalSDKInstalled()) {
        throw new Exception('Temporal SDK is not installed. To install the SDK run `composer require temporal/sdk`.');
    }
    $new = clone $this;
    $new->isTemporalEnabled = $value;
    return $new;
}

            
withTemporaryErrorHandler() public method

Returns a new instance with the specified temporary error handler instance {@see 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;
}