Allows injecting mock IO into shells
Constructor
Initializes the environment and loads the CakePHP core.
Injects mock and stub io components into the shell
Dispatch a request.
If the input matches an alias, return the aliased shell name
Defines current working environment.
Check if a shell class exists for the given name.
For all loaded plugins, add a short alias
Add an alias for a shell command.
Dispatches a CLI request
Get shell to use, either plugin shell or application shell
Shows console help. Performs an internal dispatch to the CommandList Shell
Clear any aliases that have been set.
Run the dispatcher
Removes first argument and shifts other arguments up
Prints the currently installed version of CakePHP. Performs an internal dispatch to the CommandList Shell
__construct(array $args = [], bool $bootstrap = true, Cake\Console\ConsoleIo|null $io = null)
Constructor
array
$args optional Argument array
bool
$bootstrap optional Initialize environment
Cake\Console\ConsoleIo|null
$io optional ConsoleIo
_bootstrap(): void
Initializes the environment and loads the CakePHP core.
void
_createShell(string $className, string $shortName): Cake\Console\Shell
Injects mock and stub io components into the shell
string
$className Class name
string
$shortName Short name
Cake\Console\Shell
_dispatch(array $extra = []): int|bool|null
Dispatch a request.
array
$extra optional Extra parameters that you can manually pass to the Shell to be dispatched. Built-in extra parameter is :
int|bool|null
Cake\Console\Exception\MissingShellMethodException
_handleAlias(string $shell): string
If the input matches an alias, return the aliased shell name
string
$shell Optionally the name of a plugin or alias
string
_initEnvironment(): void
Defines current working environment.
void
Cake\Core\Exception\CakeException
_shellExists(string $shell): string|null
Check if a shell class exists for the given name.
string
$shell The shell name to look for.
string|null
addShortPluginAliases(): array
For all loaded plugins, add a short alias
This permits a plugin which implements a shell of the same name to be accessed Using the shell name alone
array
alias(string $short, string|null $original = null): string|null
Add an alias for a shell command.
Aliases allow you to call shells by alternate names. This is most useful when dealing with plugin shells that you want to have shorter names for.
If you re-use an alias the last alias set will be the one available.
Aliasing a shell named ClassName:
$this->alias('alias', 'ClassName');
Getting the original name for a given alias:
$this->alias('alias');
string
$short The new short name for the shell.
string|null
$original optional The original full name for the shell.
string|null
dispatch(array $extra = []): int
Dispatches a CLI request
Converts a shell command result into an exit code. Null/True are treated as success. All other return values are an error.
array
$extra optional Extra parameters that you can manually pass to the Shell to be dispatched. Built-in extra parameter is :
int
findShell(string $shell): Cake\Console\Shell
Get shell to use, either plugin shell or application shell
All paths in the loaded shell paths are searched, handles alias dereferencing
string
$shell Optionally the name of a plugin
Cake\Console\Shell
Cake\Console\Exception\MissingShellException
help(): void
Shows console help. Performs an internal dispatch to the CommandList Shell
void
resetAliases(): void
Clear any aliases that have been set.
void
run(array $argv, array $extra = []): int
Run the dispatcher
array
$argv The argv from PHP
array
$extra optional Extra parameters
int
shiftArgs(): mixed
Removes first argument and shifts other arguments up
mixed
version(): void
Prints the currently installed version of CakePHP. Performs an internal dispatch to the CommandList Shell
void
List of connected aliases.
array<string, string>
Cake\Console\ConsoleIo
Contains arguments parsed from the command line.
array
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Console.TestSuite.LegacyShellDispatcher.html