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 $appType: Hazaar\Console\Application
options
Global options available to all commands within this module.
protected array $optionsType: array
name
Module identifier used in command routing.
private string $nameType: string
description
Human-readable module description.
private string $descriptionType: string
commands
Command definitions keyed by command name.
private array $commandsType: array
input
Parsed command-line input for the active execution.
private Input $inputType: Hazaar\Console\Input
output
Output writer used for command responses.
private Output $outputType: Hazaar\Console\Output
Methods
initialise
public initialise(Application $app, Input $input, Output $output): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$app | Hazaar\Console\Application | |
$input | Hazaar\Console\Input | |
$output | Hazaar\Console\Output |
depends
public depends(string $modules): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$modules | string |
setName
Sets the module name.
public setName(string $name): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | module identifier |
getName
Gets the configured module name.
public getName(): ?stringReturns: string
setDescription
Sets the module description.
public setDescription(string $description): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$description | string | human-readable module description |
getDescription
Gets the configured module description.
public getDescription(): ?stringReturns: string
getCommands
public getCommands(): arrayReturns: array
getCommand
Gets a command definition by name.
public getCommand(string $name): ?CommandReturns: Hazaar\Console\Command
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | command identifier |
run
Executes a registered command within this module.
public run(string $command): intReturns: int
Parses 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): selfReturns: self
Parameters
| 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 |
getOptions
Gets the global options defined for this module.
public getOptions(): arrayReturns: array
prepare
Performs module-specific pre-execution checks.
protected prepare(Input $input, Output $output): intReturns: int
Return a value greater than zero to abort command execution and return that exit code.
Parameters
| Parameter | Type | Description |
|---|---|---|
$input | Hazaar\Console\Input | parsed command input |
$output | Hazaar\Console\Output | output writer |
addCommand
Registers a command with this module.
protected addCommand(string $name, ?array $callback): CommandReturns: Hazaar\Console\Command
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | command name |
$callback | array |
configure
Configures module metadata, options, and commands.
protected configure(): voidReturns: void
Implement in subclasses to register commands and definitions.
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:18 +0000