1
当运行通过终端的命令控制器,所述 Yii::getAlias('@webroot')
不起作用=/Yii2 - 命令控制器不工作getalias根目录
命令(QueuePushNotificationController.php):
<?php
namespace app\commands;
use Yii;
use yii\console\Controller;
class QueuePushNotificationController extends Controller
{
public function actionIndex()
{
echo Yii::getAlias('@webroot');
}
}
经由终端执行:
./yii queue-push-notification
回报:
Exception 'yii\base\InvalidParamException' with message 'Invalid path alias: @webroot'
不适用于应用程序吗?
谢谢!