liufee / yii2-swoole

yii2 swoole,让yii2运行在swoole上
http://swoole.cms.qq.feehi.com
350 stars 76 forks source link

修复别名找不到 #28

Closed lantongxue closed 2 years ago

lantongxue commented 2 years ago

解决 vendor/yiisoft/yii2/web/AssetManager.php:232 产生的异常

lantongxue commented 2 years ago

主要原因是 AssetManager 的 basePath 为空,导致框架生成静态资源文件时找不到目录,大致逻辑代码如下

public $basePath = '@webroot/assets';
public $baseUrl = '@web/assets';
// some codes
public function init()
{
    parent::init();
    $this->basePath = Yii::getAlias($this->basePath);

    $this->basePath = realpath($this->basePath);
    $this->baseUrl = rtrim(Yii::getAlias($this->baseUrl), '/');
}
// some codes