PHP Класс yii\base\Application

For more details and usage information on Application, see the guide article on applications.
С версии: 2.0
Автор: Qiang Xue ([email protected])
Наследование: extends Module
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$bootstrap list of components that should be run during the application [[bootstrap()|bootstrapping process]]. Each component may be specified in one of the following formats: - an application component ID as specified via [[components]]. - a module ID as specified via [[modules]]. - a class name. - a configuration array. During the bootstrapping process, each component will be instantiated. If the component class implements BootstrapInterface, its [[BootstrapInterface::bootstrap()|bootstrap()]] method will be also be called.
$charset the charset currently used for the application.
$controller the currently active controller instance
$controllerNamespace the namespace that controller classes are located in. This namespace will be used to load controller classes by prepending it to the controller class name. The default namespace is app\controllers. Please refer to the guide about class autoloading for more details.
$extensions list of installed Yii extensions. Each array element represents a single extension with the following structure: php [ 'name' => 'extension name', 'version' => 'version number', 'bootstrap' => 'BootstrapClassName', // optional, may also be a configuration array 'alias' => [ '@alias1' => 'to/path1', '@alias2' => 'to/path2', ], ] The "bootstrap" class listed above will be instantiated during the application [[bootstrap()|bootstrapping process]]. If the class implements BootstrapInterface, its [[BootstrapInterface::bootstrap()|bootstrap()]] method will be also be called. If not set explicitly in the application config, this property will be populated with the contents of @vendor/yiisoft/extensions.php.
$language the language that is meant to be used for end users. It is recommended that you use IETF language tags. For example, en stands for English, while en-US stands for English (United States).
$layout the layout that should be applied for views in this application. Defaults to 'main'. If this is false, layout will be disabled.
$loadedModules list of loaded modules indexed by their class names.
$name the application name.
$requestedAction the requested Action. If null, it means the request cannot be resolved into an action.
$requestedParams the parameters supplied to the requested action.
$requestedRoute the requested route
$sourceLanguage the language that the application is written in. This mainly refers to the language that the messages and view files are written in.
$state the current application state during a request handling life cycle. This property is managed by the application. Do not modify this property.

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

Метод Описание
__construct ( array $config = [] ) Constructor.
coreComponents ( ) Returns the configuration of core application components.
end ( integer $status, Response $response = null ) Terminates the application.
getAssetManager ( ) : AssetManager Returns the asset manager.
getAuthManager ( ) : yii\rbac\ManagerInterface Returns the auth manager for this application.
getCache ( ) : Cache Returns the cache component.
getDb ( ) : Connection Returns the database connection component.
getErrorHandler ( ) : ErrorHandler | yii\console\ErrorHandler Returns the error handler component.
getFormatter ( ) : Formatter Returns the formatter component.
getI18n ( ) : yii\i18n\I18N Returns the internationalization (i18n) component
getLog ( ) : Dispatcher Returns the log dispatcher component.
getMailer ( ) : yii\mail\MailerInterface Returns the mailer component.
getRequest ( ) : Request | yii\console\Request Returns the request component.
getResponse ( ) : Response | yii\console\Response Returns the response component.
getRuntimePath ( ) : string Returns the directory that stores runtime files.
getSecurity ( ) : Security Returns the security component.
getTimeZone ( ) : string Returns the time zone used by this application.
getUniqueId ( ) : string Returns an ID that uniquely identifies this module among all modules within the current application.
getUrlManager ( ) : UrlManager Returns the URL manager for this application.
getVendorPath ( ) : string Returns the directory that stores vendor files.
getView ( ) : View | View Returns the view object.
handleRequest ( Request $request ) : Response Handles the specified request.
init ( )
preInit ( array &$config ) Pre-initializes the application.
run ( ) : integer Runs the application.
setBasePath ( string $path ) Sets the root directory of the application and the @app alias.
setContainer ( array $config ) Configures [[Yii::$container]] with the $config
setRuntimePath ( string $path ) Sets the directory that stores runtime files.
setTimeZone ( string $value ) Sets the time zone used by this application.
setVendorPath ( string $path ) Sets the directory that stores vendor files.

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

Метод Описание
bootstrap ( ) Initializes extensions and executes bootstrap components.
registerErrorHandler ( array &$config ) Registers the errorHandler component as a PHP error handler.

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

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

Constructor.
public __construct ( array $config = [] )
$config array name-value pairs that will be used to initialize the object properties. Note that the configuration must contain both [[id]] and [[basePath]].

bootstrap() защищенный метод

This method is called by Application::init after the application has been fully configured. If you override this method, make sure you also call the parent implementation.
protected bootstrap ( )

coreComponents() публичный метод

Returns the configuration of core application components.
См. также: set()
public coreComponents ( )

end() публичный метод

This method replaces the exit() function by ensuring the application life cycle is completed before terminating the application.
public end ( integer $status, Response $response = null )
$status integer the exit status (value 0 means normal exit while other values mean abnormal exit).
$response Response the response to be sent. If not set, the default application [[response]] component will be used.

getAssetManager() публичный метод

Returns the asset manager.
public getAssetManager ( ) : AssetManager
Результат yii\web\AssetManager the asset manager application component.

getAuthManager() публичный метод

Returns the auth manager for this application.
public getAuthManager ( ) : yii\rbac\ManagerInterface
Результат yii\rbac\ManagerInterface the auth manager application component. Null is returned if auth manager is not configured.

getCache() публичный метод

Returns the cache component.
public getCache ( ) : Cache
Результат yii\caching\Cache the cache application component. Null if the component is not enabled.

getDb() публичный метод

Returns the database connection component.
public getDb ( ) : Connection
Результат yii\db\Connection the database connection.

getErrorHandler() публичный метод

Returns the error handler component.
public getErrorHandler ( ) : ErrorHandler | yii\console\ErrorHandler
Результат yii\web\ErrorHandler | yii\console\ErrorHandler the error handler application component.

getFormatter() публичный метод

Returns the formatter component.
public getFormatter ( ) : Formatter
Результат yii\i18n\Formatter the formatter application component.

getI18n() публичный метод

Returns the internationalization (i18n) component
public getI18n ( ) : yii\i18n\I18N
Результат yii\i18n\I18N the internationalization application component.

getLog() публичный метод

Returns the log dispatcher component.
public getLog ( ) : Dispatcher
Результат yii\log\Dispatcher the log dispatcher application component.

getMailer() публичный метод

Returns the mailer component.
public getMailer ( ) : yii\mail\MailerInterface
Результат yii\mail\MailerInterface the mailer application component.

getRequest() публичный метод

Returns the request component.
public getRequest ( ) : Request | yii\console\Request
Результат yii\web\Request | yii\console\Request the request component.

getResponse() публичный метод

Returns the response component.
public getResponse ( ) : Response | yii\console\Response
Результат yii\web\Response | yii\console\Response the response component.

getRuntimePath() публичный метод

Returns the directory that stores runtime files.
public getRuntimePath ( ) : string
Результат string the directory that stores runtime files. Defaults to the "runtime" subdirectory under [[basePath]].

getSecurity() публичный метод

Returns the security component.
public getSecurity ( ) : Security
Результат Security the security application component.

getTimeZone() публичный метод

This is a simple wrapper of PHP function date_default_timezone_get(). If time zone is not configured in php.ini or application config, it will be set to UTC by default.
См. также: http://php.net/manual/en/function.date-default-timezone-get.php
public getTimeZone ( ) : string
Результат string the time zone used by this application.

getUniqueId() публичный метод

Since this is an application instance, it will always return an empty string.
public getUniqueId ( ) : string
Результат string the unique ID of the module.

getUrlManager() публичный метод

Returns the URL manager for this application.
public getUrlManager ( ) : UrlManager
Результат yii\web\UrlManager the URL manager for this application.

getVendorPath() публичный метод

Returns the directory that stores vendor files.
public getVendorPath ( ) : string
Результат string the directory that stores vendor files. Defaults to "vendor" directory under [[basePath]].

getView() публичный метод

Returns the view object.
public getView ( ) : View | View
Результат View | View the view application component that is used to render various view files.

handleRequest() абстрактный публичный метод

This method should return an instance of Response or its child class which represents the handling result of the request.
abstract public handleRequest ( Request $request ) : Response
$request Request the request to be handled
Результат Response the resulting response

init() публичный метод

public init ( )

preInit() публичный метод

This method is called at the beginning of the application constructor. It initializes several important application properties. If you override this method, please make sure you call the parent implementation.
public preInit ( array &$config )
$config array the application configuration

registerErrorHandler() защищенный метод

Registers the errorHandler component as a PHP error handler.
protected registerErrorHandler ( array &$config )
$config array application config

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

This is the main entrance of an application.
public run ( ) : integer
Результат integer the exit status (0 means normal, non-zero values mean abnormal)

setBasePath() публичный метод

This method can only be invoked at the beginning of the constructor.
public setBasePath ( string $path )
$path string the root directory of the application.

setContainer() публичный метод

Configures [[Yii::$container]] with the $config
С версии: 2.0.11
public setContainer ( array $config )
$config array values given in terms of name-value pairs

setRuntimePath() публичный метод

Sets the directory that stores runtime files.
public setRuntimePath ( string $path )
$path string the directory that stores runtime files.

setTimeZone() публичный метод

This is a simple wrapper of PHP function date_default_timezone_set(). Refer to the php manual for available timezones.
См. также: http://php.net/manual/en/function.date-default-timezone-set.php
public setTimeZone ( string $value )
$value string the time zone used by this application.

setVendorPath() публичный метод

Sets the directory that stores vendor files.
public setVendorPath ( string $path )
$path string the directory that stores vendor files.

Описание свойств

$bootstrap публичное свойство

list of components that should be run during the application [[bootstrap()|bootstrapping process]]. Each component may be specified in one of the following formats: - an application component ID as specified via [[components]]. - a module ID as specified via [[modules]]. - a class name. - a configuration array. During the bootstrapping process, each component will be instantiated. If the component class implements BootstrapInterface, its [[BootstrapInterface::bootstrap()|bootstrap()]] method will be also be called.
public $bootstrap

$charset публичное свойство

the charset currently used for the application.
public $charset

$controller публичное свойство

the currently active controller instance
public $controller

$controllerNamespace публичное свойство

the namespace that controller classes are located in. This namespace will be used to load controller classes by prepending it to the controller class name. The default namespace is app\controllers. Please refer to the guide about class autoloading for more details.
public $controllerNamespace

$extensions публичное свойство

list of installed Yii extensions. Each array element represents a single extension with the following structure: php [ 'name' => 'extension name', 'version' => 'version number', 'bootstrap' => 'BootstrapClassName', // optional, may also be a configuration array 'alias' => [ '@alias1' => 'to/path1', '@alias2' => 'to/path2', ], ] The "bootstrap" class listed above will be instantiated during the application [[bootstrap()|bootstrapping process]]. If the class implements BootstrapInterface, its [[BootstrapInterface::bootstrap()|bootstrap()]] method will be also be called. If not set explicitly in the application config, this property will be populated with the contents of @vendor/yiisoft/extensions.php.
public $extensions

$language публичное свойство

the language that is meant to be used for end users. It is recommended that you use IETF language tags. For example, en stands for English, while en-US stands for English (United States).
См. также: sourceLanguage
public $language

$layout публичное свойство

the layout that should be applied for views in this application. Defaults to 'main'. If this is false, layout will be disabled.
public $layout

$loadedModules публичное свойство

list of loaded modules indexed by their class names.
public $loadedModules

$name публичное свойство

the application name.
public $name

$requestedAction публичное свойство

the requested Action. If null, it means the request cannot be resolved into an action.
public $requestedAction

$requestedParams публичное свойство

the parameters supplied to the requested action.
public $requestedParams

$requestedRoute публичное свойство

the requested route
public $requestedRoute

$sourceLanguage публичное свойство

the language that the application is written in. This mainly refers to the language that the messages and view files are written in.
См. также: language
public $sourceLanguage

$state публичное свойство

the current application state during a request handling life cycle. This property is managed by the application. Do not modify this property.
public $state