Fr3nch13/CakePHP Utilities

HelpCommand extends BaseCommand
in package
implements CommandCollectionAwareInterface

Print out command list

Table of Contents

Interfaces

CommandCollectionAwareInterface
An interface for shells that take a CommandCollection during initialization.

Properties

$commands  : CommandCollection
The command collection to get help on.
$name  : string
The name of this command.

Methods

abort()  : void
Halt the the current process with a StopException.
defaultName()  : string
Get the command name.
execute()  : int
Main function Prints out the list of commands.
executeCommand()  : int|null
Execute another command with the provided set of arguments.
getDescription()  : string
Get the command description.
getName()  : string
Get the command name.
getOptionParser()  : ConsoleOptionParser
Get the option parser.
getRootName()  : string
Get the root command name.
initialize()  : void
Hook method invoked by CakePHP when a command is about to be executed.
run()  : int|null
Run the command.
setCommandCollection()  : void
Set the command collection being used.
setName()  : $this
Set the name this command uses in the collection.
asText()  : void
Output text.
asXml()  : void
Output as XML
buildOptionParser()  : ConsoleOptionParser
Gets the option parser instance and configures it.
displayHelp()  : void
Output help content
getShortestName()  : string
outputPaths()  : void
Output relevant paths if defined
setOutputLevel()  : void
Set the output level based on the Arguments.

Properties

$name

The name of this command.

protected string $name = 'cake unknown'

Methods

abort()

Halt the the current process with a StopException.

public abort([int $code = self::CODE_ERROR ]) : void
Parameters
$code : int = self::CODE_ERROR

The exit code to use.

Tags
throws
StopException
psalm-return

never-return

defaultName()

Get the command name.

public static defaultName() : string

Returns the command name based on class name. For e.g. for a command with class name UpdateTableCommand the default name returned would be 'update_table'.

Return values
string

executeCommand()

Execute another command with the provided set of arguments.

public executeCommand(CommandInterface|string $command[, array<string|int, mixed> $args = [] ][, ConsoleIo|null $io = null ]) : int|null

If you are using a string command name, that command's dependencies will not be resolved with the application container. Instead you will need to pass the command as an object with all of its dependencies.

Parameters
$command : CommandInterface|string

The command class name or command instance.

$args : array<string|int, mixed> = []

The arguments to invoke the command with.

$io : ConsoleIo|null = null

The ConsoleIo instance to use for the executed command.

Return values
int|null

The exit code or null for success of the command.

getDescription()

Get the command description.

public static getDescription() : string
Return values
string

getName()

Get the command name.

public getName() : string
Return values
string

getOptionParser()

Get the option parser.

public getOptionParser() : ConsoleOptionParser

You can override buildOptionParser() to define your options & arguments.

Tags
throws
RuntimeException

When the parser is invalid

Return values
ConsoleOptionParser

getRootName()

Get the root command name.

public getRootName() : string
Return values
string

initialize()

Hook method invoked by CakePHP when a command is about to be executed.

public initialize() : void

Override this method and implement expensive/important setup steps that should not run on every command run. This method will be called before the options and arguments are validated and processed.

run()

Run the command.

public run(array<string|int, mixed> $argv, ConsoleIo $io) : int|null
Parameters
$argv : array<string|int, mixed>

Arguments from the CLI environment.

$io : ConsoleIo

The console io

Tags
inheritDoc
Return values
int|null

Exit code or null for success.

setName()

Set the name this command uses in the collection.

public setName(string $name) : $this
Parameters
$name : string

The name the command uses in the collection.

Tags
inheritDoc
Return values
$this

asText()

Output text.

protected asText(ConsoleIo $io, iterable<string|int, mixed> $commands) : void
Parameters
$io : ConsoleIo

The console io

$commands : iterable<string|int, mixed>

The command collection to output.

asXml()

Output as XML

protected asXml(ConsoleIo $io, iterable<string|int, mixed> $commands) : void
Parameters
$io : ConsoleIo

The console io

$commands : iterable<string|int, mixed>

The command collection to output

getShortestName()

protected getShortestName(array<string|int, string> $names) : string
Parameters
$names : array<string|int, string>

Names

Return values
string

        
On this page

Search results