1.下面这些别名都是在Yii2里面系统定义的,可以直接拿来就用

'@yii' =>
      '@yii/swiftmailer' => string 'C:\wamp\www\advanced\vendor/yiisoft/yii2-swiftmailer' (length=52)
      '@yii/gii' => string 'C:\wamp\www\advanced\vendor/yiisoft/yii2-gii' (length=44)
      '@yii/faker' => string 'C:\wamp\www\advanced\vendor/yiisoft/yii2-faker' (length=46)
      '@yii/debug' => string 'C:\wamp\www\advanced\vendor/yiisoft/yii2-debug' (length=46)
      '@yii/codeception' => string 'C:\wamp\www\advanced\vendor/yiisoft/yii2-codeception' (length=52)
      '@yii/bootstrap' => string 'C:\wamp\www\advanced\vendor/yiisoft/yii2-bootstrap' (length=50)
      '@yii' => string 'C:\wamp\www\advanced\vendor\yiisoft\yii2' (length=40)
  '@app' => string 'C:\wamp\www\advanced\frontend' (length=29)
  '@vendor' => string 'C:\wamp\www\advanced/vendor' (length=27)
  '@bower' => string 'C:\wamp\www\advanced/vendor\bower' (length=33)
  '@npm' => string 'C:\wamp\www\advanced/vendor\npm' (length=31)
  '@runtime' => string 'C:\wamp\www\advanced\frontend\runtime' (length=37)
  '@webroot' => string 'C:/wamp/www/advanced/frontend/web' (length=33)
  '@web' => string '/advanced/frontend/web' (length=22)

2.其他方法

1、在index.PHP文件中使用dirname(__FILE__),并保存
2、使用Yii::app()->basePath, 这个指向的是protected目录,再回退一级目录即可:Yii::app()->basePath.'/../'

上一篇:IE6中fixed抖动问题的解决(转载)

下一篇:Yii2学习笔记二十七:不用composer 手动安装插件