ConfigModule
ConfigModule
Class ConfigModule.
Console module for viewing and modifying application configuration. Provides commands to show, check, and get configuration values.
Methods
prepareApp
Prepares the application by resolving and validating the application path.
public prepareApp(Input $input, Output $output): intThis method retrieves the application path from the input options. If the path is not absolute, it attempts to locate the application path using Application::findAppPath(). If the application path cannot be found, it writes an error message to the output and returns 1. Otherwise, it initializes the application loader with the resolved path.
Parameters
| Parameter | Type | Description |
|---|---|---|
$input | Input | the input interface containing command options |
$output | Output | the output interface for writing messages |
configure
Configures the console module by registering methods and commands.
protected configure(): void- Registers the 'prepareApp' method.
- Sets the module name to 'config' and provides a description.
- Adds the following commands:
- 'show': Displays the application configuration.
- 'check': Checks the application configuration.
- 'get': Views a specific configuration option, requires an 'option' argument.
showConfig
Displays the application configuration for the specified environment.
protected showConfig(Input $input, Output $output): intRetrieves the environment option from the input, defaults to the APPLICATION_ENV constant or 'development' if not set. Loads the application configuration for the determined environment, outputs the environment, and then lists all configuration values in dot notation format.
Parameters
| Parameter | Type | Description |
|---|---|---|
$input | Input | the input interface for receiving command options |
$output | Output | the output interface for writing command output |
getConfigItem
Retrieves and outputs a configuration item based on the provided input arguments and options.
protected getConfigItem(Input $input, Output $output): intThis method fetches the environment option (or uses the APPLICATION_ENV constant or 'development' as fallback), opens the application configuration for that environment, and retrieves the specified configuration argument. If the configuration value is an array, it is flattened and formatted for output; otherwise, it is output as a simple key-value pair. The result is written to the provided output interface.
Parameters
| Parameter | Type | Description |
|---|---|---|
$input | Input | the input interface containing command-line arguments and options |
$output | Output | the output interface for writing the result |
checkConfig
Checks if the application configuration exists for the specified environment.
protected checkConfig(Input $input, Output $output): intRetrieves the environment option from the input or falls back to the APPLICATION_ENV constant, defaulting to 'development' if neither is set. Attempts to open the 'app' configuration for the determined environment. If no configuration is found, writes a message to the output and returns 1. Otherwise, confirms the configuration is found and returns 0.
Parameters
| Parameter | Type | Description |
|---|---|---|
$input | Input | the input interface for retrieving command options |
$output | Output | the output interface for writing messages |
Generated by Hazaar API Doc Generator on Sun, 01 Mar 2026 09:22:27 +0000