Neuron-PHP

Registry
in package

Registry for managing CLI commands.

Stores command name to class mappings and provides methods for registration and retrieval.

Table of Contents

Properties

$commands  : array<string, string>

Methods

all()  : array<string, string>
Get all registered commands
clear()  : void
Clear all registered commands
count()  : int
Get the count of registered commands
find()  : array<string, string>
Find commands by pattern
get()  : string|null
Get a command class by name
getByNamespace()  : array<string, string>
Get commands in a specific namespace
getNamespaces()  : array<string|int, string>
Get all command namespaces (parts before the colon)
has()  : bool
Check if a command is registered
register()  : void
Register a command
remove()  : bool
Remove a command from the registry

Properties

$commands

private array<string, string> $commands = []

Command name to class mappings

Methods

all()

Get all registered commands

public all() : array<string, string>
Return values
array<string, string>

clear()

Clear all registered commands

public clear() : void

count()

Get the count of registered commands

public count() : int
Return values
int

find()

Find commands by pattern

public find(string $pattern) : array<string, string>
Parameters
$pattern : string

Pattern to match (supports wildcards with *)

Return values
array<string, string>

Matching commands

get()

Get a command class by name

public get(string $name) : string|null
Parameters
$name : string
Return values
string|null

Command class name or null if not found

getByNamespace()

Get commands in a specific namespace

public getByNamespace(string $namespace) : array<string, string>
Parameters
$namespace : string
Return values
array<string, string>

getNamespaces()

Get all command namespaces (parts before the colon)

public getNamespaces() : array<string|int, string>
Return values
array<string|int, string>

has()

Check if a command is registered

public has(string $name) : bool
Parameters
$name : string
Return values
bool

register()

Register a command

public register(string $name, string $class) : void
Parameters
$name : string

Command name (e.g., 'cms:init')

$class : string

Fully qualified class name

remove()

Remove a command from the registry

public remove(string $name) : bool
Parameters
$name : string
Return values
bool

True if command was removed, false if it didn't exist


        
On this page

Search results