Command

Base class for all commands.

Known subclasses

ApiGen\Console\Command\GenerateCommand
Methods Summary
public
# __construct( string|null $name = NULL )
Constructor.
public
# ignoreValidationErrors( )
Ignores validation errors. This is mainly useful for the help command.
public
# setApplication( Symfony\Component\Console\Application $application = NULL )
Sets the application instance for this command.
public
# setHelperSet( Symfony\Component\Console\Helper\HelperSet $helperSet )
Sets the helper set.
public
# getHelperSet( )
Gets the helper set.
public
# getApplication( )
Gets the application instance for this command.
public
# isEnabled( )
Checks whether the command is enabled or not in the current environment. Override this to check for x or y and return false if the command can not run properly under the current conditions.
protected
# configure( )
Configures the current command.
protected
# execute( Symfony\Component\Console\Input\InputInterface $input , Symfony\Component\Console\Output\OutputInterface $output )
Executes the current command. This method is not abstract because you can use this class as a concrete class. In this case, instead of defining the execute() method, you set the code to execute by passing a Closure to the setCode() method.

see

setCode()
protected
# interact( Symfony\Component\Console\Input\InputInterface $input , Symfony\Component\Console\Output\OutputInterface $output )
Interacts with the user. This method is executed before the InputDefinition is validated. This means that this is the only place where the command can interactively ask for values of missing required arguments.
protected
# initialize( Symfony\Component\Console\Input\InputInterface $input , Symfony\Component\Console\Output\OutputInterface $output )
Initializes the command just after the input has been validated. This is mainly useful when a lot of commands extends one main command where some things need to be initialized based on the input arguments and options.
public
# run( Symfony\Component\Console\Input\InputInterface $input , Symfony\Component\Console\Output\OutputInterface $output )
Runs the command. The code to execute is either defined directly with the setCode() method or by overriding the execute() method in a sub-class.

see

setCode()

see

execute()
public
# setCode( callable $code )
Sets the code to execute when running this command. If this method is used, it overrides the code defined in the execute() method.

see

execute()
public
# mergeApplicationDefinition( bool $mergeArgs = true )
Merges the application definition with the command definition. This method is not part of public API and should not be used directly.
public
# setDefinition( array|\InputDefinition $definition )
Sets an array of argument and option instances.
public
# getDefinition( )
Gets the InputDefinition attached to this Command.
public
# getNativeDefinition( )
Gets the InputDefinition to be used to create representations of this Command. Can be overridden to provide the original command representation when it would otherwise be changed by merging with the application InputDefinition. This method is not part of public API and should not be used directly.
public
# addArgument( string $name , int $mode = NULL, string $description = '', mixed $default = NULL )
Adds an argument.
public
# addOption( string $name , string $shortcut = NULL, int $mode = NULL, string $description = '', mixed $default = NULL )
Adds an option.
public
# setName( string $name )
Sets the name of the command. This method can set both the namespace and the name if you separate them by a colon (:) $command->setName('foo:bar');
public
# setProcessTitle( string $title )
Sets the process title of the command. This feature should be used only when creating a long process command, like a daemon. PHP 5.5+ or the proctitle PECL library is required
public
# getName( )
Returns the command name.
public
# setHidden( bool $hidden )
public
# isHidden( )
public
# setDescription( string $description )
Sets the description for the command.
public
# getDescription( )
Returns the description for the command.
public
# setHelp( string $help )
Sets the help for the command.
public
# getHelp( )
Returns the help for the command.
public
# getProcessedHelp( )
Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
public
# setAliases( string[] $aliases )
Sets the aliases for the command.
public
# getAliases( )
Returns the aliases for the command.
public
# getSynopsis( bool $short = false )
Returns the synopsis for the command.
public
# addUsage( string $usage )
Add a command usage example.
public
# getUsages( )
Returns alternative usages of the command.
public
# getHelper( string $name )
Gets a helper instance by name.