PHP Класс Symfony\Component\Console\Application

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( string $name = 'UNKNOWN', string $version = 'UNKNOWN' )
add ( Command $command ) : Command | null Adds a command object.
addCommands ( array $commands ) Adds an array of command objects.
all ( string $namespace = null ) : Command[] Gets the commands (registered in the given namespace if provided).
areExceptionsCaught ( ) : boolean Gets whether to catch exceptions or not during commands execution.
doRun ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer Runs the current application.
extractNamespace ( string $name, string $limit = null ) : string Returns the namespace part of the command name.
find ( string $name ) : Command Finds a command by name or alias.
findNamespace ( string $namespace ) : string Finds a registered namespace by a name or an abbreviation.
get ( string $name ) : Command Returns a registered command by name or alias.
getAbbreviations ( array $names ) : array Returns an array of possible abbreviations given a set of names.
getDefinition ( ) : Symfony\Component\Console\Input\InputDefinition Gets the InputDefinition related to this Application.
getHelp ( ) : string Gets the help message.
getHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet Get the helper set associated with the command.
getLongVersion ( ) : string Returns the long version of the application.
getName ( ) : string Gets the name of the application.
getNamespaces ( ) : string[] Returns an array of all unique namespaces used by currently registered commands.
getTerminalDimensions ( ) : array Tries to figure out the terminal dimensions based on the current environment.
getVersion ( ) : string Gets the application version.
has ( string $name ) : boolean Returns true if the command exists, false otherwise.
isAutoExitEnabled ( ) : boolean Gets whether to automatically exit after a command execution or not.
register ( string $name ) : Command Registers a new command.
renderException ( Exception $e, Symfony\Component\Console\Output\OutputInterface $output ) Renders a caught exception.
run ( Symfony\Component\Console\Input\InputInterface $input = null, Symfony\Component\Console\Output\OutputInterface $output = null ) : integer Runs the current application.
setAutoExit ( boolean $boolean ) Sets whether to automatically exit after a command execution or not.
setCatchExceptions ( boolean $boolean ) Sets whether to catch exceptions or not during commands execution.
setDefaultCommand ( string $commandName, boolean $isSingleCommand = false ) : self Sets the default Command name.
setDefinition ( Symfony\Component\Console\Input\InputDefinition $definition ) Set an input definition to be used with this application.
setDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher )
setHelperSet ( Symfony\Component\Console\Helper\HelperSet $helperSet ) Set a helper set to be used with the command.
setName ( string $name ) Sets the application name.
setTerminalDimensions ( integer $width, integer $height ) : Application Sets terminal dimensions.
setVersion ( string $version ) Sets the application version.

Защищенные методы

Метод Описание
configureIO ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) Configures the input and output instances based on the user arguments and options.
doRunCommand ( Command $command, Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer Runs the current command.
getCommandName ( Symfony\Component\Console\Input\InputInterface $input ) : string Gets the name of the command based on input.
getDefaultCommands ( ) : Command[] Gets the default commands that should always be available.
getDefaultHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet Gets the default helper set with the helpers that should always be available.
getDefaultInputDefinition ( ) : Symfony\Component\Console\Input\InputDefinition Gets the default input definition.
getTerminalHeight ( ) : integer | null Tries to figure out the terminal height in which this application runs.
getTerminalWidth ( ) : integer | null Tries to figure out the terminal width in which this application runs.

Приватные методы

Метод Описание
extractAllNamespaces ( string $name ) : string[] Returns all namespaces of the command name.
findAlternatives ( string $name, array | Traversable $collection ) : string[] Finds alternative of $name among $collection, if nothing is found in $collection, try in $abbrevs.
getAbbreviationSuggestions ( array $abbrevs ) : string Returns abbreviated suggestions in string format.
splitStringByWidth ( $string, $width )
stringWidth ( $string )

Описание методов

__construct() публичный Метод

public __construct ( string $name = 'UNKNOWN', string $version = 'UNKNOWN' )
$name string The name of the application
$version string The version of the application

add() публичный Метод

If a command with the same name already exists, it will be overridden. If the command is not enabled it will not be added.
public add ( Command $command ) : Command | null
$command Symfony\Component\Console\Command\Command A Command object
Результат Symfony\Component\Console\Command\Command | null The registered command if enabled or null

addCommands() публичный Метод

If a Command is not enabled it will not be added.
public addCommands ( array $commands )
$commands array An array of commands

all() публичный Метод

The array keys are the full names and the values the command instances.
public all ( string $namespace = null ) : Command[]
$namespace string A namespace name
Результат Symfony\Component\Console\Command\Command[] An array of Command instances

areExceptionsCaught() публичный Метод

Gets whether to catch exceptions or not during commands execution.
public areExceptionsCaught ( ) : boolean
Результат boolean Whether to catch exceptions or not during commands execution

configureIO() защищенный Метод

Configures the input and output instances based on the user arguments and options.
protected configureIO ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface An InputInterface instance
$output Symfony\Component\Console\Output\OutputInterface An OutputInterface instance

doRun() публичный Метод

Runs the current application.
public doRun ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer
$input Symfony\Component\Console\Input\InputInterface An Input instance
$output Symfony\Component\Console\Output\OutputInterface An Output instance
Результат integer 0 if everything went fine, or an error code

doRunCommand() защищенный Метод

If an event dispatcher has been attached to the application, events are also dispatched during the life-cycle of the command.
protected doRunCommand ( Command $command, Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer
$command Symfony\Component\Console\Command\Command A Command instance
$input Symfony\Component\Console\Input\InputInterface An Input instance
$output Symfony\Component\Console\Output\OutputInterface An Output instance
Результат integer 0 if everything went fine, or an error code

extractNamespace() публичный Метод

This method is not part of public API and should not be used directly.
public extractNamespace ( string $name, string $limit = null ) : string
$name string The full name of the command
$limit string The maximum number of parts of the namespace
Результат string The namespace of the command

find() публичный Метод

Contrary to get, this command tries to find the best match if you give it an abbreviation of a name or alias.
public find ( string $name ) : Command
$name string A command name or a command alias
Результат Symfony\Component\Console\Command\Command A Command instance

findNamespace() публичный Метод

Finds a registered namespace by a name or an abbreviation.
public findNamespace ( string $namespace ) : string
$namespace string A namespace or abbreviation to search for
Результат string A registered namespace

get() публичный Метод

Returns a registered command by name or alias.
public get ( string $name ) : Command
$name string The command name or alias
Результат Symfony\Component\Console\Command\Command A Command object

getAbbreviations() публичный статический Метод

Returns an array of possible abbreviations given a set of names.
public static getAbbreviations ( array $names ) : array
$names array An array of names
Результат array An array of abbreviations

getCommandName() защищенный Метод

Gets the name of the command based on input.
protected getCommandName ( Symfony\Component\Console\Input\InputInterface $input ) : string
$input Symfony\Component\Console\Input\InputInterface The input interface
Результат string The command name

getDefaultCommands() защищенный Метод

Gets the default commands that should always be available.
protected getDefaultCommands ( ) : Command[]
Результат Symfony\Component\Console\Command\Command[] An array of default Command instances

getDefaultHelperSet() защищенный Метод

Gets the default helper set with the helpers that should always be available.
protected getDefaultHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet
Результат Symfony\Component\Console\Helper\HelperSet A HelperSet instance

getDefaultInputDefinition() защищенный Метод

Gets the default input definition.
protected getDefaultInputDefinition ( ) : Symfony\Component\Console\Input\InputDefinition
Результат Symfony\Component\Console\Input\InputDefinition An InputDefinition instance

getDefinition() публичный Метод

Gets the InputDefinition related to this Application.
public getDefinition ( ) : Symfony\Component\Console\Input\InputDefinition
Результат Symfony\Component\Console\Input\InputDefinition The InputDefinition instance

getHelp() публичный Метод

Gets the help message.
public getHelp ( ) : string
Результат string A help message

getHelperSet() публичный Метод

Get the helper set associated with the command.
public getHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet
Результат Symfony\Component\Console\Helper\HelperSet The HelperSet instance associated with this command

getLongVersion() публичный Метод

Returns the long version of the application.
public getLongVersion ( ) : string
Результат string The long application version

getName() публичный Метод

Gets the name of the application.
public getName ( ) : string
Результат string The application name

getNamespaces() публичный Метод

It does not return the global namespace which always exists.
public getNamespaces ( ) : string[]
Результат string[] An array of namespaces

getTerminalDimensions() публичный Метод

Tries to figure out the terminal dimensions based on the current environment.
Устаревший: since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
public getTerminalDimensions ( ) : array
Результат array Array containing width and height

getTerminalHeight() защищенный Метод

Tries to figure out the terminal height in which this application runs.
Устаревший: since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
protected getTerminalHeight ( ) : integer | null
Результат integer | null

getTerminalWidth() защищенный Метод

Tries to figure out the terminal width in which this application runs.
Устаревший: since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
protected getTerminalWidth ( ) : integer | null
Результат integer | null

getVersion() публичный Метод

Gets the application version.
public getVersion ( ) : string
Результат string The application version

has() публичный Метод

Returns true if the command exists, false otherwise.
public has ( string $name ) : boolean
$name string The command name or alias
Результат boolean true if the command exists, false otherwise

isAutoExitEnabled() публичный Метод

Gets whether to automatically exit after a command execution or not.
public isAutoExitEnabled ( ) : boolean
Результат boolean Whether to automatically exit after a command execution or not

register() публичный Метод

Registers a new command.
public register ( string $name ) : Command
$name string The command name
Результат Symfony\Component\Console\Command\Command The newly created command

renderException() публичный Метод

Renders a caught exception.
public renderException ( Exception $e, Symfony\Component\Console\Output\OutputInterface $output )
$e Exception An exception instance
$output Symfony\Component\Console\Output\OutputInterface An OutputInterface instance

run() публичный Метод

Runs the current application.
public run ( Symfony\Component\Console\Input\InputInterface $input = null, Symfony\Component\Console\Output\OutputInterface $output = null ) : integer
$input Symfony\Component\Console\Input\InputInterface An Input instance
$output Symfony\Component\Console\Output\OutputInterface An Output instance
Результат integer 0 if everything went fine, or an error code

setAutoExit() публичный Метод

Sets whether to automatically exit after a command execution or not.
public setAutoExit ( boolean $boolean )
$boolean boolean Whether to automatically exit after a command execution or not

setCatchExceptions() публичный Метод

Sets whether to catch exceptions or not during commands execution.
public setCatchExceptions ( boolean $boolean )
$boolean boolean Whether to catch exceptions or not during commands execution

setDefaultCommand() публичный Метод

Sets the default Command name.
public setDefaultCommand ( string $commandName, boolean $isSingleCommand = false ) : self
$commandName string The Command name
$isSingleCommand boolean Set to true if there is only one command in this application
Результат self

setDefinition() публичный Метод

Set an input definition to be used with this application.
public setDefinition ( Symfony\Component\Console\Input\InputDefinition $definition )
$definition Symfony\Component\Console\Input\InputDefinition The input definition

setDispatcher() публичный Метод

public setDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher )
$dispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface

setHelperSet() публичный Метод

Set a helper set to be used with the command.
public setHelperSet ( Symfony\Component\Console\Helper\HelperSet $helperSet )
$helperSet Symfony\Component\Console\Helper\HelperSet The helper set

setName() публичный Метод

Sets the application name.
public setName ( string $name )
$name string The application name

setTerminalDimensions() публичный Метод

Can be useful to force terminal dimensions for functional tests.
Устаревший: since version 3.2, to be removed in 4.0. Set the COLUMNS and LINES env vars instead.
public setTerminalDimensions ( integer $width, integer $height ) : Application
$width integer The width
$height integer The height
Результат Application The current application

setVersion() публичный Метод

Sets the application version.
public setVersion ( string $version )
$version string The application version