-
Notifications
You must be signed in to change notification settings - Fork 51
Customize The Application
The global behaviour can be modified as follows:
-
$this->enableCommandAutoload()
to enable command autoloading. - Creating a new
CLIFramework\ServiceContainer
, overriding known fields with custom implementations and passing it to theCLIFramework\Application
constructor. -
runWithTry($argv)
catches some exceptions (like malformatted commands) and prints them nicely, whilerun($argv)
does not catch any exceptions.
Application options are registered the same as command options. The default implementation has quite a few useful built-in options. To keep these options enabled, make sure to call parent::options($opts)
in the overridden options($opts): void
method.
Application commands are registered the same as subcommands. The default implemenation has several built-in commands. Call parent::init()
in the overriden init(): void
method to keep these commands active. Even without calling the parent implementation, you probably always want to register the built-in help command using $this->command('help', \CLIFramework\Command\HelpCommand::class)
.
Application lifecycle hooks are the same as the command lifecycle hooks, but you cannot implement the execute
method.