final class CommandRegistry (View source)

Registers command metadata and resolves command names and aliases for execution.

Methods

Creates a registry that resolves command implementations through the container.

void
register(string|CommandInterface $command)

Registers a legacy command whose metadata must be read from an instance.

void
void

Registers command metadata and all aliases as one atomic namespace entry.

void
bool
has(string $name)

Reports whether a primary command name or alias is registered.

bool
get(string $name)

Resolves a registered command implementation by primary name or alias.

definition(string $name)

Returns command metadata by primary name or alias without instantiating the command.

array

Returns all definitions sorted by their primary command name.

array
array
all()

Resolves all registered commands in primary-name order.

array

Details

__construct

__construct(ContainerInterface $container)

Creates a registry that resolves command implementations through the container.

Parameters

ContainerInterface $container

register

void register(string|CommandInterface $command)

Registers a legacy command whose metadata must be read from an instance.

New code should register a definition so listing commands remains lazy.

Parameters

string|CommandInterface $command

Return Value

void

Exceptions

RuntimeException

registerDefinition

void registerDefinition(CommandDefinition $definition)

Registers command metadata and all aliases as one atomic namespace entry.

Parameters

CommandDefinition $definition

Return Value

void

Exceptions

RuntimeException

has

bool has(string $name)

Reports whether a primary command name or alias is registered.

Parameters

string $name

Return Value

bool

get

CommandInterface get(string $name)

Resolves a registered command implementation by primary name or alias.

This legacy lookup resolves through the root container; normal execution should use the CLI kernel.

Parameters

string $name

Return Value

CommandInterface

Exceptions

RuntimeException

definition

CommandDefinition definition(string $name)

Returns command metadata by primary name or alias without instantiating the command.

Parameters

string $name

Return Value

CommandDefinition

Exceptions

RuntimeException

allDefinitions

array allDefinitions()

Returns all definitions sorted by their primary command name.

Return Value

array

all

array all()

Resolves all registered commands in primary-name order.

Return Value

array