Breaking News
Home / Web / PHP / PHP FAQ / What are the various alias used in Yii 2.0 ?

What are the various alias used in Yii 2.0 ?

The following are the various alias used by the Yii Framework. These alias simply programming as the full path or value represented by the alias does not need to be typed again and again along with that if needed these alias can be changed in a single place.

@yii – framework directory.
@app – base path of currently running application.
@common – common directory.
@frontend – frontend web application directory.
@backend – backend web application directory.
@console – console directory.
@runtime – runtime directory of currently running web application.
@vendor – Composer vendor directory.
@web – base URL of currently running web application.
@webroot – web root directory of currently running web application.

These alias are defined in aliases.php in the config directory of the Yii project.

<?php
Yii::setAlias(‘common’, dirname(__DIR__));
Yii::setAlias(‘frontend’, dirname(dirname(__DIR__)) . ‘/frontend’);
Yii::setAlias(‘backend’, dirname(dirname(__DIR__)) . ‘/backend’);
Yii::setAlias(‘console’, dirname(dirname(__DIR__)) . ‘/console’);

 

 [pb_builder]

Check Also

How does fopen function work in PHP?

fopen() Function The fopen() function opens a specified file or URL for reading and/or writing. The syntax …

Advertisment ad adsense adlogger