参考文章 yii2 asset合并压缩(多个资源文件配置) - 教程 - Yii Framework 中文网
首先是各种目录找不到的问题
Exception 'yii\base\InvalidArgumentException' with message 'The file or directory to be published does not exist: /Applications/MAMP/htdocs/shiqidu.2018.com/vendor/npm/bootstrap4c-chosen'
Exception 'yii\base\InvalidArgumentException' with message 'The file or directory to be published does not exist: /Applications/MAMP/htdocs/shiqidu.2018.com/vendor/bower/bootstrap/dist'
vendor目录下没有brower 和 npm这两个目录,真实目录的名字是bower-asset和npm-asset,所需需要我们设置一下别名。
在assets.php文件中添加下面两行。
Yii::setAlias('@bower', __DIR__ . '/vendor/bower-asset');
Yii::setAlias('@npm', __DIR__ . '/vendor/npm-asset');
然后是目录权限问题
PHP Warning 'yii\base\ErrorException' with message 'file_put_contents(/Applications/MAMP/htdocs/shiqidu.2018.com/web/assets/js/all-temp.js.tmp): failed to open stream: No such file or directory'
因为没有权限所以创建目录失败,直接手动在web/assets目录下创建js目录即可。