Collection for Commands.
Used by Applications to specify their console commands. CakePHP will use the mapped commands to construct and dispatch shell commands.
array
Command list
Automatically discover shell commands in CakePHP, the application and all plugins.
__construct(array $commands)
Constructor
array
$commands optional The map of commands to add to the collection.
add(string $name, mixed $command)
Add a command to the collection
string
$name The name of the command you want to map.
string|\Cake\Console\Shell|\Cake\Console\CommandInterface
$command The command to map. Can be a FQCN, Shell instance or CommandInterface instance.
$this
InvalidArgumentException
addMany(array $commands)
Add multiple commands at once.
array
$commands A map of command names => command classes/instances.
$this
autoDiscover()
Automatically discover shell commands in CakePHP, the application and all plugins.
Commands will be located using filesystem conventions. Commands are discovered in the following order:
Commands defined in the application will ovewrite commands with the same name provided by CakePHP.
string[]
An array of command names and their classes.
count()
Implementation of Countable.
Get the number of commands in the collection.
int
discoverPlugin(string $plugin)
Auto-discover shell & commands from the named plugin.
Discovered commands will have their names de-duplicated with existing commands in the collection. If a command is already defined in the collection and discovered in a plugin, only the long name (plugin.command
) will be returned.
string
$plugin The plugin to scan.
string[]
Discovered plugin commands.
get(string $name)
Get the target for a command.
string
$name The named shell.
string|\Cake\Console\Shell|\Cake\Console\CommandInterface
Either the command class or an instance.
InvalidArgumentException
getIterator()
Implementation of IteratorAggregate.
\Traversable
has(string $name)
Check whether the named shell exists in the collection.
string
$name The named shell.
bool
keys()
Get the list of available command names.
string[]
Command names
remove(string $name)
Remove a command from the collection if it exists.
string
$name The named shell.
$this
resolveNames(array $input)
Resolve names based on existing commands
array
$input The results of a CommandScanner operation.
string[]
A flat map of command names => class names.
Command list
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.1/class-Cake.Console.CommandCollection.html