final class CliKernelFactory (View source)

Factory for constructing CLI application kernels.

The factory accepts an optional preconfigured container and optional stdout and stderr streams. When no container is supplied, it creates a new default container, then wires a Framework instance and a CliKernel instance around the provided application context. The factory itself does not bootstrap the application or dispatch commands.

Methods

__construct(ContainerInterface|null $container = null, mixed $stdout = null, mixed $stderr = null)

Creates a factory with optional container and output stream overrides.

Creates a new CLI kernel for the given application context.

Details

__construct

__construct(ContainerInterface|null $container = null, mixed $stdout = null, mixed $stderr = null)

Creates a factory with optional container and output stream overrides.

The container is reused for both the framework and the resulting CLI kernel. When stdout or stderr is omitted, the created kernel falls back to its default stream handling.

Parameters

ContainerInterface|null $container
mixed $stdout
mixed $stderr

Exceptions

InvalidArgumentException

create

Creates a new CLI kernel for the given application context.

The factory uses the provided container or creates a new default container, builds a framework instance over the same context and container, and returns a CLI kernel that shares the same context, container, framework, and configured streams. The method does not bootstrap the kernel or run a command.

Parameters

ApplicationContext $context

Return Value

CliKernel