自定义别名:
<?php
namespace frontend\controllers;
use Yii;
use yii\web\Controller;
class RbacController extends Controller
{
public function actionIndex(){
Yii::setAlias("@foo", 'http://www.example.com');var_dump(Yii::getAlias("@foo"));}}
系统别名::只需要获取即可:
<?php
namespace frontend\controllers;
use Yii;
use yii\web\Controller;
class RbacController extends Controller
{
public function actionIndex(){
var_dump(Yii::getAlias("@yii"));var_dump(Yii::getAlias("@app"));var_dump(Yii::getAlias("@webroot"));var_dump(Yii::getAlias("@web"));var_dump(Yii::getAlias("@bower"));var_dump(Yii::getAlias("@npm"));}}