InstallCommand
extends Command
in package
Install the CMS admin UI into the project
Publishes view templates, creates directories, and sets up initial admin user
Table of Contents
Properties
- $arguments : array<string|int, mixed>
- $input : Input
- $inputReader : IInputReader|null
- $options : array<string|int, mixed>
- $output : Output
- $_componentPath : string
- $_messages : array<string|int, mixed>
- $_projectPath : string
Methods
- __construct() : mixed
- configure() : void
- Configure the command
- execute() : int
- Execute the command
- getArguments() : array<string|int, mixed>
- Get all configured arguments
- getDescription() : string
- Get the command description
- getHelp() : string
- Get the help text for this command
- getName() : string
- Get the command name
- getOptions() : array<string|int, mixed>
- Get all configured options
- hasArgument() : bool
- Check if the command has a specific argument
- hasOption() : bool
- Check if the command has a specific option
- setInput() : self
- Set the input instance
- setInputReader() : self
- Set the input reader (for dependency injection, especially in tests).
- setOutput() : self
- Set the output instance
- validate() : void
- Validate that required arguments are present
- addArgument() : self
- Add an argument to the command
- addOption() : self
- Add an option to the command
- arrayToYaml() : string
- Convert array to YAML format (simple implementation)
- choice() : string
- Prompt user to select from a list of options.
- configureApplication() : array<string|int, mixed>
- Configure application settings
- configureCloudinary() : array<string|int, mixed>
- Configure Cloudinary (optional)
- configureDatabaseUrl() : array<string|int, mixed>
- Configure database using URL
- configureEmail() : array<string|int, mixed>
- Configure Email (optional)
- configureMysql() : array<string|int, mixed>
- Configure MySQL
- configurePostgresql() : array<string|int, mixed>
- Configure PostgreSQL
- configureSqlite() : array<string|int, mixed>
- Configure SQLite
- confirm() : bool
- Ask user for yes/no confirmation.
- copyDirectory() : bool
- Copy directory recursively
- copyGitignoreTemplate() : bool
- Copy .gitignore template to config directory
- copyMigrations() : bool
- Copy database migrations from component to project
- createAdminUser() : bool
- Create admin user interactively
- createAuthConfig() : bool
- Create auth configuration
- createDirectories() : bool
- Create necessary directories
- createPublicFiles() : bool
- Create public folder and copy all static assets
- createRouteConfig() : bool
- Create route configuration
- displaySummary() : void
- Display installation summary
- getInputReader() : IInputReader
- Get the input reader instance.
- isAlreadyInstalled() : bool
- Check if CMS is already installed
- prompt() : string
- Prompt user for input.
- publishInitializers() : bool
- Publish initializers
- publishViews() : bool
- Publish view templates
- runMigration() : bool
- Run the migration
- saveCompleteConfig() : bool
- Save complete configuration with all required sections
- saveConfig() : bool
- Save configuration to YAML file
- saveConfigWithSecrets() : bool
- Save configuration with encrypted secrets
- secret() : string
- Prompt for sensitive input without echoing to console.
- seedDefaultData() : bool
- Seed default data after migration
- setupDatabase() : bool
- Setup database configuration
- updateGitignore() : bool
- Update .gitignore to exclude key files
- yamlValue() : string
- Format value for YAML
Properties
$arguments
protected
array<string|int, mixed>
$arguments
= []
$input
protected
Input
$input
$inputReader
protected
IInputReader|null
$inputReader
= null
$options
protected
array<string|int, mixed>
$options
= []
$output
protected
Output
$output
$_componentPath
private
string
$_componentPath
$_messages
private
array<string|int, mixed>
$_messages
= []
$_projectPath
private
string
$_projectPath
Methods
__construct()
public
__construct() : mixed
configure()
Configure the command
public
configure() : void
execute()
Execute the command
public
execute([array<string|int, mixed> $parameters = [] ]) : int
Parameters
- $parameters : array<string|int, mixed> = []
Return values
int —Exit code (0 for success)
getArguments()
Get all configured arguments
public
getArguments() : array<string|int, mixed>
Return values
array<string|int, mixed>getDescription()
Get the command description
public
getDescription() : string
Tags
Return values
stringgetHelp()
Get the help text for this command
public
getHelp() : string
Return values
stringgetName()
Get the command name
public
getName() : string
Tags
Return values
stringgetOptions()
Get all configured options
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>hasArgument()
Check if the command has a specific argument
public
hasArgument(string $name) : bool
Parameters
- $name : string
Return values
boolhasOption()
Check if the command has a specific option
public
hasOption(string $name) : bool
Parameters
- $name : string
Return values
boolsetInput()
Set the input instance
public
setInput(Input $input) : self
Parameters
- $input : Input
Return values
selfsetInputReader()
Set the input reader (for dependency injection, especially in tests).
public
setInputReader(IInputReader $inputReader) : self
This allows tests to inject a TestInputReader with pre-programmed responses instead of requiring actual user input.
Parameters
- $inputReader : IInputReader
Return values
selfsetOutput()
Set the output instance
public
setOutput(Output $output) : self
Parameters
- $output : Output
Return values
selfvalidate()
Validate that required arguments are present
public
validate() : void
Tags
addArgument()
Add an argument to the command
protected
addArgument(string $name[, bool $required = false ][, string $description = '' ][, mixed $default = null ]) : self
Parameters
- $name : string
-
Argument name
- $required : bool = false
-
Whether the argument is required
- $description : string = ''
-
Description of the argument
- $default : mixed = null
-
Default value if not provided
Return values
selfaddOption()
Add an option to the command
protected
addOption(string $name[, string|null $shortcut = null ][, bool $hasValue = false ][, string $description = '' ][, mixed $default = null ]) : self
Parameters
- $name : string
-
Option name (long form)
- $shortcut : string|null = null
-
Option shortcut (single character)
- $hasValue : bool = false
-
Whether the option accepts a value
- $description : string = ''
-
Description of the option
- $default : mixed = null
-
Default value if not provided
Return values
selfarrayToYaml()
Convert array to YAML format (simple implementation)
protected
arrayToYaml(array<string|int, mixed> $data[, int $indent = 0 ]) : string
Parameters
- $data : array<string|int, mixed>
- $indent : int = 0
Return values
stringchoice()
Prompt user to select from a list of options.
protected
choice(string $message, array<string|int, string> $options[, string|null $default = null ]) : string
Convenience method that delegates to the input reader. Users can select by entering either the option index (numeric) or the exact option text.
Example:
$env = $this->choice(
"Select environment:",
['development', 'staging', 'production'],
'development'
);
Parameters
- $message : string
-
The prompt message
- $options : array<string|int, string>
-
Available options
- $default : string|null = null
-
Default option (will be marked with *)
Return values
string —The selected option
configureApplication()
Configure application settings
protected
configureApplication() : array<string|int, mixed>
Return values
array<string|int, mixed>configureCloudinary()
Configure Cloudinary (optional)
protected
configureCloudinary() : array<string|int, mixed>
Return values
array<string|int, mixed>configureDatabaseUrl()
Configure database using URL
protected
configureDatabaseUrl() : array<string|int, mixed>
Return values
array<string|int, mixed>configureEmail()
Configure Email (optional)
protected
configureEmail() : array<string|int, mixed>
Return values
array<string|int, mixed>configureMysql()
Configure MySQL
protected
configureMysql() : array<string|int, mixed>
Return values
array<string|int, mixed>configurePostgresql()
Configure PostgreSQL
protected
configurePostgresql() : array<string|int, mixed>
Return values
array<string|int, mixed>configureSqlite()
Configure SQLite
protected
configureSqlite() : array<string|int, mixed>
Return values
array<string|int, mixed>confirm()
Ask user for yes/no confirmation.
protected
confirm(string $message[, bool $default = false ]) : bool
Convenience method that delegates to the input reader. Accepts: y, yes, true, 1 (case-insensitive) as positive responses.
Example:
if( $this->confirm( "Delete all files?" ) ) {
// User confirmed
}
Parameters
- $message : string
-
The confirmation message
- $default : bool = false
-
Default value if user just presses enter
Return values
bool —True if user confirms, false otherwise
copyDirectory()
Copy directory recursively
protected
copyDirectory(string $source, string $dest) : bool
Parameters
- $source : string
- $dest : string
Return values
boolcopyGitignoreTemplate()
Copy .gitignore template to config directory
protected
copyGitignoreTemplate() : bool
Return values
boolcopyMigrations()
Copy database migrations from component to project
protected
copyMigrations() : bool
Return values
boolcreateAdminUser()
Create admin user interactively
protected
createAdminUser() : bool
Return values
boolcreateAuthConfig()
Create auth configuration
protected
createAuthConfig() : bool
Return values
boolcreateDirectories()
Create necessary directories
protected
createDirectories() : bool
Return values
boolcreatePublicFiles()
Create public folder and copy all static assets
protected
createPublicFiles() : bool
Return values
boolcreateRouteConfig()
Create route configuration
protected
createRouteConfig() : bool
Return values
booldisplaySummary()
Display installation summary
protected
displaySummary() : void
getInputReader()
Get the input reader instance.
protected
getInputReader() : IInputReader
Creates a default StdinInputReader if not already set. This enables testable CLI commands by abstracting user input.
If output hasn't been set, a default Output instance will be created automatically.
Return values
IInputReaderisAlreadyInstalled()
Check if CMS is already installed
protected
isAlreadyInstalled() : bool
Return values
boolprompt()
Prompt user for input.
protected
prompt(string $message) : string
Convenience method that delegates to the input reader.
Example:
$name = $this->prompt( "Enter your name: " );
Parameters
- $message : string
-
The prompt message to display
Return values
string —The user's response (trimmed)
publishInitializers()
Publish initializers
protected
publishInitializers() : bool
Return values
boolpublishViews()
Publish view templates
protected
publishViews() : bool
Return values
boolrunMigration()
Run the migration
protected
runMigration() : bool
Return values
boolsaveCompleteConfig()
Save complete configuration with all required sections
protected
saveCompleteConfig(array<string|int, mixed> $databaseConfig, array<string|int, mixed> $appConfig[, array<string|int, mixed> $cloudinaryConfig = [] ][, array<string|int, mixed> $emailConfig = [] ][, bool $useSecrets = false ]) : bool
Parameters
- $databaseConfig : array<string|int, mixed>
- $appConfig : array<string|int, mixed>
- $cloudinaryConfig : array<string|int, mixed> = []
- $emailConfig : array<string|int, mixed> = []
- $useSecrets : bool = false
Return values
boolsaveConfig()
Save configuration to YAML file
protected
saveConfig(array<string|int, mixed> $config) : bool
Parameters
- $config : array<string|int, mixed>
Return values
boolsaveConfigWithSecrets()
Save configuration with encrypted secrets
protected
saveConfigWithSecrets(array<string|int, mixed> $publicConfig, array<string|int, mixed> $secretsConfig) : bool
Parameters
- $publicConfig : array<string|int, mixed>
- $secretsConfig : array<string|int, mixed>
Return values
boolsecret()
Prompt for sensitive input without echoing to console.
protected
secret(string $message) : string
Convenience method that delegates to the input reader. Note: Secret input hiding only works on Unix-like systems.
Example:
$password = $this->secret( "Enter password: " );
Parameters
- $message : string
-
The prompt message
Return values
string —The user's input (trimmed)
seedDefaultData()
Seed default data after migration
protected
seedDefaultData() : bool
Return values
boolsetupDatabase()
Setup database configuration
protected
setupDatabase([bool $useSecrets = false ]) : bool
Parameters
- $useSecrets : bool = false
Return values
boolupdateGitignore()
Update .gitignore to exclude key files
protected
updateGitignore() : bool
Return values
boolyamlValue()
Format value for YAML
protected
yamlValue(mixed $value) : string
Parameters
- $value : mixed