Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CConsoleApplication
  • CConsoleCommand
  • CConsoleCommandBehavior
  • CConsoleCommandEvent
  • CConsoleCommandRunner
  • CHelpCommand
  • ThemeBuildCommand
  • Overview
  • Package
  • Class
  • Tree

Class CConsoleApplication

CConsoleApplication represents a console application.

CConsoleApplication extends CApplication by providing functionalities specific to console requests. In particular, it deals with console requests through a command-based approach:
  • A console application consists of one or several possible user commands;
  • Each user command is implemented as a class extending CConsoleCommand;
  • User specifies which command to run on the command line;
  • The command processes the user request with the specified parameters.

The command classes reside in the directory getCommandPath commandPath. The name of the class follows the pattern: <command-name>Command, and its file name is the same as the class name. For example, the 'ShellCommand' class defines a 'shell' command and the class file name is 'ShellCommand.php'.

To run the console application, enter the following on the command line:

php path/to/entry_script.php <command name> [param 1] [param 2] ...

You may use the following to see help instructions about a command:

php path/to/entry_script.php help <command name>
CComponent
Extended by CModule
Extended by CApplication
Extended by CConsoleApplication
Package: system\console
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/console/CConsoleApplication.php
Methods summary
protected
# init( )

Initializes the application by creating the command runner.

Initializes the application by creating the command runner.

Overrides

CModule::init()
public
# processRequest( )

Processes the user request. This method uses a console command runner to handle the particular user command. Since version 1.1.11 this method will exit application with an exit code if one is returned by the user command.

Processes the user request. This method uses a console command runner to handle the particular user command. Since version 1.1.11 this method will exit application with an exit code if one is returned by the user command.

protected CConsoleCommandRunner
# createCommandRunner( )

Creates the command runner instance.

Creates the command runner instance.

Returns

CConsoleCommandRunner
the command runner
public
# displayError( integer $code, string $message, string $file, string $line )

Displays the captured PHP error. This method displays the error in console mode when there is no active error handler.

Displays the captured PHP error. This method displays the error in console mode when there is no active error handler.

Parameters

$code
integer
$code error code
$message
string
$message error message
$file
string
$file error file
$line
string
$line error line

Overrides

CApplication::displayError()
public
# displayException( Exception $exception )

Displays the uncaught PHP exception. This method displays the exception in console mode when there is no active error handler.

Displays the uncaught PHP exception. This method displays the exception in console mode when there is no active error handler.

Parameters

$exception
Exception
$exception the uncaught exception

Overrides

CApplication::displayException()
public string
# getCommandPath( )

Returns

string
the directory that contains the command classes. Defaults to 'protected/commands'.
public
# setCommandPath( string $value )

Parameters

$value
string
$value the directory that contains the command classes.

Throws

CException
if the directory is invalid
public CConsoleCommandRunner
# getCommandRunner( )

Returns the command runner.

Returns the command runner.

Returns

CConsoleCommandRunner
the command runner.
public CConsoleCommand|null
# getCommand( )

Returns the currently running command. This is shortcut method for CConsoleCommandRunner::getCommand().

Returns the currently running command. This is shortcut method for CConsoleCommandRunner::getCommand().

Returns

CConsoleCommand|null
the currently active command.

Since

1.1.14
public
# setCommand( CConsoleCommand $value )

This is shortcut method for CConsoleCommandRunner::setCommand().

This is shortcut method for CConsoleCommandRunner::setCommand().

Parameters

$value
CConsoleCommand
$value the currently active command.

Since

1.1.14
Methods inherited from CApplication
__construct(), clearGlobalState(), createAbsoluteUrl(), createUrl(), end(), findLocalizedFile(), getBasePath(), getBaseUrl(), getCache(), getController(), getCoreMessages(), getDateFormatter(), getDb(), getErrorHandler(), getExtensionPath(), getGlobalState(), getHomeUrl(), getId(), getLanguage(), getLocale(), getLocaleDataPath(), getMessages(), getNumberFormatter(), getRequest(), getRuntimePath(), getSecurityManager(), getStatePersister(), getTimeZone(), getUrlManager(), handleError(), handleException(), initSystemHandlers(), loadGlobalState(), onBeginRequest(), onEndRequest(), onError(), onException(), registerCoreComponents(), run(), saveGlobalState(), setBasePath(), setExtensionPath(), setGlobalState(), setHomeUrl(), setId(), setLanguage(), setLocaleDataPath(), setRuntimePath(), setTimeZone()
Methods inherited from CModule
__get(), __isset(), configure(), getComponent(), getComponents(), getModule(), getModulePath(), getModules(), getParams(), getParentModule(), hasComponent(), hasModule(), preinit(), preloadComponents(), setAliases(), setComponent(), setComponents(), setImport(), setModulePath(), setModules(), setParams()
Methods inherited from CComponent
__call(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public array $commandMap array()
#

mapping from command name to command configurations. Each command configuration can be either a string or an array. If the former, the string should be the file path of the command class. If the latter, the array must contain a 'class' element which specifies the command's class name or YiiBase::getPathOfAlias class path alias. The rest name-value pairs in the array are used to initialize the corresponding command properties. For example,

array(
  'email'=>array(
     'class'=>'path.to.Mailer',
     'interval'=>3600,
  ),
  'log'=>'path/to/LoggerCommand.php',
)

mapping from command name to command configurations. Each command configuration can be either a string or an array. If the former, the string should be the file path of the command class. If the latter, the array must contain a 'class' element which specifies the command's class name or YiiBase::getPathOfAlias class path alias. The rest name-value pairs in the array are used to initialize the corresponding command properties. For example,

array(
  'email'=>array(
     'class'=>'path.to.Mailer',
     'interval'=>3600,
  ),
  'log'=>'path/to/LoggerCommand.php',
)
Properties inherited from CApplication
$charset, $localeClass, $name, $sourceLanguage
Properties inherited from CModule
$behaviors, $preload
Magic properties summary
public string $commandPath
#

The directory that contains the command classes. Defaults to 'protected/commands'.

The directory that contains the command classes. Defaults to 'protected/commands'.

public CConsoleCommandRunner $commandRunner
#

The command runner.

The command runner.

public CConsoleCommand $command
#

The currently active command.

The currently active command.

Magic properties inherited from CApplication
$basePath, $baseUrl, $cache, $controller, $coreMessages, $dateFormatter, $db, $errorHandler, $extensionPath, $homeUrl, $id, $language, $locale, $localeDataPath, $messages, $numberFormatter, $request, $runtimePath, $securityManager, $statePersister, $timeZone, $urlManager
Magic properties inherited from CModule
$aliases, $components, $import, $modulePath, $modules, $params, $parentModule
API documentation generated by ApiGen 2.8.0