PHP 클래스 yii\console\Application

Application extends from Application by providing functionalities that are 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 Controller; - User specifies which command to run on the command line; - The command processes the user request with the specified parameters. The command classes should be under the namespace specified by [[controllerNamespace]]. Their naming should follow the same naming convention as controllers. For example, the help command is implemented using the HelpController class. To run the console application, enter the following on the command line: ~~~ yii [--param1=value1 --param2 ...] ~~~ where refers to a controller route in the form of ModuleID/ControllerID/ActionID (e.g. sitemap/create), and param1, param2 refers to a set of named parameters that will be used to initialize the controller action (e.g. --since=0 specifies a since parameter whose value is 0 and a corresponding $since parameter is passed to the action method). A help command is provided by default, which lists available commands and shows their usage. To use this command, simply type: ~~~ yii help ~~~
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\base\Application
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$controller the currently active controller instance
$defaultRoute the default route of this application. Defaults to 'help', meaning the help command.
$enableCoreCommands whether to enable the commands provided by the core framework. Defaults to true.

공개 메소드들

메소드 설명
__construct ( $config = [] )
coreCommands ( ) : array Returns the configuration of the built-in commands.
coreComponents ( )
getErrorHandler ( ) : yii\console\ErrorHandler Returns the error handler component.
getRequest ( ) : yii\console\Request Returns the request component.
getResponse ( ) : Response Returns the response component.
handleRequest ( yii\console\Request $request ) : Response Handles the specified request.
init ( ) Initialize the application.
runAction ( string $route, array $params = [] ) : integer | Response Runs a controller action specified by a route.

보호된 메소드들

메소드 설명
loadConfig ( array $config ) : array Loads the configuration.

메소드 상세

__construct() 공개 메소드

public __construct ( $config = [] )

coreCommands() 공개 메소드

Returns the configuration of the built-in commands.
public coreCommands ( ) : array
리턴 array the configuration of the built-in commands.

coreComponents() 공개 메소드

public coreComponents ( )

getErrorHandler() 공개 메소드

Returns the error handler component.
public getErrorHandler ( ) : yii\console\ErrorHandler
리턴 yii\console\ErrorHandler the error handler application component.

getRequest() 공개 메소드

Returns the request component.
public getRequest ( ) : yii\console\Request
리턴 yii\console\Request the request component.

getResponse() 공개 메소드

Returns the response component.
public getResponse ( ) : Response
리턴 Response the response component.

handleRequest() 공개 메소드

Handles the specified request.
public handleRequest ( yii\console\Request $request ) : Response
$request yii\console\Request the request to be handled
리턴 Response the resulting response

init() 공개 메소드

Initialize the application.
public init ( )

loadConfig() 보호된 메소드

This method will check if the command line option [[OPTION_APPCONFIG]] is specified. If so, the corresponding file will be loaded as the application configuration. Otherwise, the configuration provided as the parameter will be returned back.
protected loadConfig ( array $config ) : array
$config array the configuration provided in the constructor.
리턴 array the actual configuration to be used by the application.

runAction() 공개 메소드

This method parses the specified route and creates the corresponding child module(s), controller and action instances. It then calls [[Controller::runAction()]] to run the action with the given parameters. If the route is empty, the method will use [[defaultRoute]]. For example, to run public function actionTest($a, $b) assuming that the controller has options the following code should be used: php \Yii::$app->runAction('controller/test', ['option' => 'value', $a, $b]);
public runAction ( string $route, array $params = [] ) : integer | Response
$route string the route that specifies the action.
$params array the parameters to be passed to the action
리턴 integer | Response the result of the action. This can be either an exit code or Response object. Exit code 0 means normal, and other values mean abnormal. Exit code of `null` is treaded as `0` as well.

프로퍼티 상세

$controller 공개적으로 프로퍼티

the currently active controller instance
public $controller

$defaultRoute 공개적으로 프로퍼티

the default route of this application. Defaults to 'help', meaning the help command.
public $defaultRoute

$enableCoreCommands 공개적으로 프로퍼티

whether to enable the commands provided by the core framework. Defaults to true.
public $enableCoreCommands