首页 > 代码库 > Yii2 composer更新后报错: Calling unknown method: yii\web\UrlManager::addRules()
Yii2 composer更新后报错: Calling unknown method: yii\web\UrlManager::addRules()
网上搜了好多答案,基本上都是让你在composer.json里面添加这样一段话:
"extra": { "asset-installer-paths": { "npm-asset-library": "vendor/npm", "bower-asset-library": "vendor/bower", "npm-searchable": false, "bower-searchable": false } }
因为自己也不是很清楚什么原因,我就如此这般的跟着操作,可是怎么弄都不行,依然会报同样的错! 刚学Yii2,好多东西都还不懂,遇到这样的问题真TM蛋疼,,,
折腾了好久,后来在官网上搜到了这样一段话,抱着试试看的心态,还真解决了!!
首先:假如你的项目名为myproject 在你的项目根目录里面使用composer(右键->Use Composer here)
我英语不好,下面就不在翻译,原文如下:
Step1:composer global require "fxp/composer-asset-plugin:1.0.*@dev"
Step2:composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced myproject
Step3:copy and past to composer.json at ‘require‘, then run composer --prefer-dist update:
"bower-asset/jquery": "@stable",
"bower-asset/bootstrap": "@stable",
"bower-asset/jquery-ui": "@stable",
"bower-asset/jquery.inputmask": "@stable",
"bower-asset/punycode": "@stable"
Step4:Run composer --prefer-dist update
然后在浏览器中刷新项目,一切OK.
Yii2 composer更新后报错: Calling unknown method: yii\web\UrlManager::addRules()