Module
Module
Base class for console command modules.
class ModuleA module groups related console commands, defines metadata and shared options, and coordinates command preparation/execution using parsed input and output helpers.
Properties
app
Console application instance that owns this module.
protected Application $appoptions
Global options available to all commands within this module.
protected array $optionsname
Module identifier used in command routing.
private string $namedescription
Human-readable module description.
private string $descriptioncommands
Command definitions keyed by command name.
private array $commandsinput
Parsed command-line input for the active execution.
private Input $inputoutput
Output writer used for command responses.
private Output $outputMethods
initialise
public initialise(Application $app, Input $input, Output $output): voidParameters
| Parameter | Type | Description |
|---|---|---|
$app | Application | |
$input | Input | |
$output | Output |
depends
public depends(string $modules): selfParameters
| Parameter | Type | Description |
|---|---|---|
$modules | string |
setName
Sets the module name.
public setName(string $name): selfParameters
| Parameter | Type | Description |
|---|---|---|
$name | string | module identifier |
getName
Gets the configured module name.
public getName(): ?stringsetDescription
Sets the module description.
public setDescription(string $description): selfParameters
| Parameter | Type | Description |
|---|---|---|
$description | string | human-readable module description |
getDescription
Gets the configured module description.
public getDescription(): ?stringgetCommands
public getCommands(): voidgetCommand
Gets a command definition by name.
public getCommand(string $name): ?CommandParameters
| Parameter | Type | Description |
|---|---|---|
$name | string | command identifier |
run
Executes a registered command within this module.
public run(string $command): intParses command input, runs module preparation, and invokes the command callback when available.
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | string | command name to execute |
addOption
Adds a global option available to all commands.
public addOption(string $long, ?string $short, ?string $description, ?bool $takesValue, mixed $default, ?string $valueType): selfParameters
| Parameter | Type | Description |
|---|---|---|
$long | string | long option name |
$short | string | optional short option alias |
$description | string | optional option description |
$takesValue | bool | whether the option accepts a value |
$default | mixed | default value for the option |
$valueType | string | optional expected value type |
prepare
Performs module-specific pre-execution checks.
protected prepare(Input $input, Output $output): intReturn a value greater than zero to abort command execution and return that exit code.
Parameters
| Parameter | Type | Description |
|---|---|---|
$input | Input | parsed command input |
$output | Output | output writer |
addCommand
Registers a command with this module.
protected addCommand(string $name, ?array $callback): CommandParameters
| Parameter | Type | Description |
|---|---|---|
$name | string | command name |
$callback | array |
configure
Configures module metadata, options, and commands.
protected configure(): voidImplement in subclasses to register commands and definitions.
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000