Google News
logo
Yii framework - Interview Questions
What is Applications in Yii Framework?
Applications are objects that govern the overall structure and lifecycle of Yii application systems. Each Yii application system contains a single application object which is created in the entry script and is globally accessible through the expression \Yii::$app.
 
Info: Depending on the context, when we say "an application", it can mean either an application object or an application system.
 
There are two types of applications : Web applications and console applications. As the names indicate, the former mainly handles Web requests, while the latter handles console command requests.
 
Application Configurations : When an entry script creates an application, it will load a configuration and apply it to the application, as follows:
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';

// load application configuration
$config = require __DIR__ . '/../config/web.php';

// instantiate and configure the application
(new yii\web\Application($config))->run();
Like normal configurations, application configurations specify how to initialize properties of application objects. Because application configurations are often very complex, they usually are kept in configuration files, like the web.php file in the above example.
Advertisement