Overview

Namespaces

  • Webmozart
    • Console
      • Adapter
      • Api
        • Application
        • Args
          • Format
        • Command
        • Config
        • Event
        • Formatter
        • IO
        • Resolver
      • Args
      • Config
      • Formatter
      • Handler
        • Help
      • IO
        • InputStream
        • OutputStream
      • Process
      • Resolver
      • UI
        • Alignment
        • Component
        • Help
        • Layout
        • Style
      • Util

Classes

  • ApplicationConfig
  • CommandConfig
  • Config
  • OptionCommandConfig
  • SubCommandConfig
  • Overview
  • Namespace
  • Class

Class ApplicationConfig

The configuration of a console application.

Webmozart\Console\Api\Config\Config
Extended by Webmozart\Console\Api\Config\ApplicationConfig

Direct known subclasses

Webmozart\Console\Config\DefaultApplicationConfig
Namespace: Webmozart\Console\Api\Config
Author: Bernhard Schussek bschussek@gmail.com
Since: 1.0
Located at Api/Config/ApplicationConfig.php
Methods summary
public static static
# create( string $name = null, string $version = null )

Creates a new console application.

Creates a new console application.

Parameters

$name
The name of the application.
$version
The application version.

Returns

static
The created instance.
public
# __construct( string $name = null, string $version = null )

Creates a new console application.

Creates a new console application.

Parameters

$name
The name of the application.
$version
The application version.

Overrides

Webmozart\Console\Api\Config\Config::__construct()
public string
# getName( )

Returns the name of the application.

Returns the name of the application.

Returns

string
The application name.

See

Webmozart\Console\Api\Config\ApplicationConfig::setName()
public static
# setName( string $name )

Sets the name of the application.

Sets the name of the application.

Parameters

$name
The application name.

Returns

static
The current instance.

See

Webmozart\Console\Api\Config\ApplicationConfig::getName()
public string
# getDisplayName( )

Returns the application name as it is displayed in the help.

Returns the application name as it is displayed in the help.

If no display name is set with Webmozart\Console\Api\Config\ApplicationConfig::setDisplayName(), the humanized application name is returned.

Returns

string
The display name.

See

Webmozart\Console\Api\Config\ApplicationConfig::setDisplayName()
public static
# setDisplayName( string $displayName )

Sets the application name as it is displayed in the help.

Sets the application name as it is displayed in the help.

Parameters

$displayName
The display name.

Returns

static
The current instance.

See

Webmozart\Console\Api\Config\ApplicationConfig::getDisplayName()
public string
# getVersion( )

Returns the version of the application.

Returns the version of the application.

Returns

string
The application version.
public static
# setVersion( string $version )

Sets the version of the application.

Sets the version of the application.

Parameters

$version
The application version.

Returns

static
The current instance.
public string
# getHelp( )

Returns the help text of the application.

Returns the help text of the application.

Returns

string
The help text.
public static
# setHelp( string $help )

Sets the help text of the application.

Sets the help text of the application.

Parameters

$help
The help text.

Returns

static
The current instance.
public Symfony\Component\EventDispatcher\EventDispatcherInterface
# getEventDispatcher( )

Returns the event dispatcher used to dispatch the console events.

Returns the event dispatcher used to dispatch the console events.

Returns

Symfony\Component\EventDispatcher\EventDispatcherInterface
The event dispatcher.
public static
# setEventDispatcher( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher = null )

Sets the event dispatcher for dispatching the console events.

Sets the event dispatcher for dispatching the console events.

Parameters

$dispatcher
The event dispatcher.

Returns

static
The current instance.
public static
# addEventListener( string $eventName, callable $listener, integer $priority = 0 )

Adds a listener for the given event name.

Adds a listener for the given event name.

See ConsoleEvents for the supported event names.

Parameters

$eventName
The event to listen to.
$listener

The callback to execute when the event is dispatched.

$priority
The event priority.

Returns

static
The current instance.

See

EventDispatcherInterface::addListener()
public static
# addEventSubscriber( Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber )

Adds an event subscriber to the dispatcher.

Adds an event subscriber to the dispatcher.

Parameters

$subscriber
The subscriber to add.

Returns

static
The current instance.

See

EventDispatcherInterface::addSubscriber()
public static
# removeEventListener( string $eventName, callable $listener )

Removes an event listener for the given event name.

Removes an event listener for the given event name.

Parameters

$eventName
The event name.
$listener
The callback to remove.

Returns

static
The current instance.

See

EventDispatcherInterface::removeListener()
public static
# removeEventSubscriber( Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber )

Removes an event subscriber from the dispatcher.

Removes an event subscriber from the dispatcher.

Parameters

$subscriber
The subscriber to remove.

Returns

static
The current instance.

See

EventDispatcherInterface::removeSubscriber()
public boolean
# isExceptionCaught( )

Returns whether the application catches and displays exceptions thrown while running a command.

Returns whether the application catches and displays exceptions thrown while running a command.

Returns

boolean

Returns true if exceptions are caught and false otherwise.

See

Webmozart\Console\Api\Config\ApplicationConfig::setCatchExceptions()
public static
# setCatchExceptions( boolean $catch )

Sets whether the application catches and displays exceptions thrown while running a command.

Sets whether the application catches and displays exceptions thrown while running a command.

Parameters

$catch

Whether to catch and display exceptions thrown while running a command.

Returns

static
The current instance.

See

Webmozart\Console\Api\Config\ApplicationConfig::isExceptionCaught()
public boolean
# isTerminatedAfterRun( )

Returns whether the PHP process is terminated after running a command.

Returns whether the PHP process is terminated after running a command.

Returns

boolean

Returns true if the PHP process is terminated after run() and false otherwise.

See

Webmozart\Console\Api\Config\ApplicationConfig::setTerminateAfterRun()
public static
# setTerminateAfterRun( boolean $terminate )

Sets whether to terminate the PHP process after running a command.

Sets whether to terminate the PHP process after running a command.

Parameters

$terminate

Whether to terminate the PHP process after running a command.

Returns

static
The current instance.

See

Webmozart\Console\Api\Config\ApplicationConfig::isTerminatedAfterRun()
public Webmozart\Console\Api\Resolver\CommandResolver
# getCommandResolver( )

Returns the used command resolver.

Returns the used command resolver.

Returns

Webmozart\Console\Api\Resolver\CommandResolver
The command resolver.

See

Webmozart\Console\Api\Config\ApplicationConfig::setCommandResolver()
public static
# setCommandResolver( Webmozart\Console\Api\Resolver\CommandResolver $commandResolver )

Sets the used command resolver.

Sets the used command resolver.

Parameters

$commandResolver
The command resolver.

Returns

static
The current instance.

See

Webmozart\Console\Api\Config\ApplicationConfig::getCommandResolver()
public callable
# getIOFactory( )

Returns the callable used to create IO instances.

Returns the callable used to create IO instances.

Returns

callable
The callable or null if none was set.

See

Webmozart\Console\Api\Config\ApplicationConfig::setIOFactory()
public static
# setIOFactory( callable $ioFactory )

Sets the callable used to create IO instances.

Sets the callable used to create IO instances.

The callable receives four arguments: * RawArgs: The raw console arguments. * Input: The input. * Output: The output. * Output: The error output.

The input and output instances may be null if none were passed to Application::run().

Parameters

$ioFactory
The IO factory callable.

Returns

static
The current instance.
public boolean
# isDebug( )

Returns whether the application is in debug mode.

Returns whether the application is in debug mode.

In debug mode, the verbosity is always IO::DEBUG.

Returns

boolean
Returns true if the application is in debug mode.

See

Webmozart\Console\Api\Config\ApplicationConfig::setDebug()
public static
# setDebug( boolean $debug )

Sets whether the application is in debug mode.

Sets whether the application is in debug mode.

In debug mode, the verbosity is always IO::DEBUG.

Parameters

$debug
Set to true to activate the debug mode.

Returns

static
The current instance.

See

Webmozart\Console\Api\Config\ApplicationConfig::isDebug()
public Webmozart\Console\Api\Formatter\StyleSet
# getStyleSet( )

Returns the configured style set.

Returns the configured style set.

Returns

Webmozart\Console\Api\Formatter\StyleSet
The style set.

See

Webmozart\Console\Api\Config\ApplicationConfig::setStyleSet()
public static
# setStyleSet( Webmozart\Console\Api\Formatter\StyleSet $styleSet )

Sets the used style set.

Sets the used style set.

Parameters

$styleSet
The style set to use.

Returns

static
The current instance.

See

Webmozart\Console\Api\Config\ApplicationConfig::getStyleSet()
public static
# addStyle( Webmozart\Console\Api\Formatter\Style $style )

Adds a style to the style set.

Adds a style to the style set.

Parameters

$style
The style to add.

Returns

static
The current instance.

See

StyleSet::add()
public static
# addStyles( array $styles )

Adds multiple styles to the style set.

Adds multiple styles to the style set.

Parameters

$styles
The styles to add.

Returns

static
The current instance.

See

StyleSet::merge()
public static
# removeStyle( string $tag )

Removes a style from the style set.

Removes a style from the style set.

Parameters

$tag
The tag of the style to remove.

Returns

static
The current instance.

See

StyleSet::remove()
public Webmozart\Console\Api\Config\CommandConfig
# beginCommand( string $name )

Starts a configuration block for a command.

Starts a configuration block for a command.

The configuration of the command is returned by this method. You can use the fluent interface to configure the sub-command before jumping back to this configuration with CommandConfig::end():

protected function configure()
{ $this ->setName('server') ->setDescription('List and manage servers')
 ->beginCommand('add') ->setDescription('Add a server') ->addArgument('host', Argument::REQUIRED) ->addOption('port', 'p', Option::VALUE_OPTIONAL, null, 80) ->end()
 // ... ;
}

Parameters

$name
The name of the command.

Returns

Webmozart\Console\Api\Config\CommandConfig
The command configuration.

See

Webmozart\Console\Api\Config\ApplicationConfig::editCommand()
public Webmozart\Console\Api\Config\CommandConfig
# editCommand( string $name )

Alias for Webmozart\Console\Api\Config\ApplicationConfig::getCommandConfig().

Alias for Webmozart\Console\Api\Config\ApplicationConfig::getCommandConfig().

This method can be used to nicely edit a command inherited from a parent configuration using the fluent API:

protected function configure()
{ parent::configure();
 $this ->editCommand('add') // ... ->end()
 // ... ;
}

Parameters

$name
The name of the command to edit.

Returns

Webmozart\Console\Api\Config\CommandConfig
The command configuration.

See

Webmozart\Console\Api\Config\ApplicationConfig::beginCommand()
public static
# addCommandConfig( Webmozart\Console\Api\Config\CommandConfig $config )

Adds a command configuration to the application.

Adds a command configuration to the application.

Parameters

$config
The command configuration.

Returns

static
The current instance.

See

Webmozart\Console\Api\Config\ApplicationConfig::beginCommand()
public static
# addCommandConfigs( array $configs )

Adds command configurations to the application.

Adds command configurations to the application.

Parameters

$configs
The command configurations.

Returns

static
The current instance.

See

Webmozart\Console\Api\Config\ApplicationConfig::beginCommand()
public static
# setCommandConfigs( array $configs )

Sets the command configurations of the application.

Sets the command configurations of the application.

Parameters

$configs
The command configurations.

Returns

static
The current instance.

See

Webmozart\Console\Api\Config\ApplicationConfig::beginCommand()
public Webmozart\Console\Api\Config\CommandConfig
# getCommandConfig( string $name )

Returns the command configuration for a given name.

Returns the command configuration for a given name.

Parameters

$name
The name of the command.

Returns

Webmozart\Console\Api\Config\CommandConfig
The command configuration.

Throws

Webmozart\Console\Api\Command\NoSuchCommandException
If the command configuration is not found.

See

Webmozart\Console\Api\Config\ApplicationConfig::beginCommand()
public Webmozart\Console\Api\Config\CommandConfig[]
# getCommandConfigs( )

Returns all registered command configurations.

Returns all registered command configurations.

Returns

Webmozart\Console\Api\Config\CommandConfig[]
The command configurations.

See

Webmozart\Console\Api\Config\ApplicationConfig::beginCommand()
public boolean
# hasCommandConfig( string $name )

Returns whether the application has a command with a given name.

Returns whether the application has a command with a given name.

Parameters

$name
The name of the command.

Returns

boolean

Returns true if the command configuration with the given name exists and false otherwise.

See

Webmozart\Console\Api\Config\ApplicationConfig::beginCommand()
public boolean
# hasCommandConfigs( )

Returns whether the application has any registered command configurations.

Returns whether the application has any registered command configurations.

Returns

boolean

Returns true if command configurations were added to the application and false otherwise.

See

Webmozart\Console\Api\Config\ApplicationConfig::beginCommand()
protected string
# getDefaultDisplayName( )

Returns the default display name used if no display name is set.

Returns the default display name used if no display name is set.

Returns

string
The default display name.
Methods inherited from Webmozart\Console\Api\Config\Config
addArgument(), addOption(), configure(), disableLenientArgsParsing(), enableLenientArgsParsing(), getArgsParser(), getArguments(), getDefaultArgsParser(), getDefaultHandler(), getDefaultHandlerMethod(), getDefaultHelperSet(), getDefaultLenientArgsParsing(), getHandler(), getHandlerMethod(), getHelperSet(), getOptions(), isLenientArgsParsingEnabled(), setArgsParser(), setHandler(), setHandlerMethod(), setHelperSet()
Webmozart Console API API documentation generated by ApiGen