Yii2 错误:yiiaseUnknownMethodException:调用未知方法:yiiwebUrlManager::addRules() [英] Yii2 Error: yiiaseUnknownMethodException: Calling unknown method: yiiwebUrlManager::addRules()

查看:18
本文介绍了Yii2 错误:yiiaseUnknownMethodException:调用未知方法:yiiwebUrlManager::addRules()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在今天更新 Composer 依赖项(使用 composer update 命令)后,我的 Yii2 应用程序损坏了 - 它抛出 Unknown Method – yiiaseUnknownMethodException: Calling unknown method: yiiwebUrlManager::addRules()

After todays update of composer dependencies (with composer update command) my Yii2 application became broken - It throws Unknown Method – yiiaseUnknownMethodException: Calling unknown method: yiiwebUrlManager::addRules()

在检查 vendor/yiisoft/yii2/web/UrlManager.php 文件后,我发现没有方法 addRule.并且整个类 UrlManager 与存储库中的类不同.

After inspecting vendor/yiisoft/yii2/web/UrlManager.php file I found that there is no method addRule. And the whole entire class UrlManager is different from the class in the repository.

我的 composer.json:

My composer.json:

"minimum-stability": "dev",
"require": {
    "php": ">=5.4.0",
    "yiisoft/yii2": "*",
    "yiisoft/yii2-bootstrap": "*",
    "yiisoft/yii2-swiftmailer": "*",
    "yiisoft/yii2-gii": "2.0.0-beta",
    "claudejanz/yii2-mygii": "*",
    "kartik-v/yii2-grid": "dev-master",
    "kartik-v/yii2-builder": "dev-master",
    "2amigos/yii2-switch-widget": "*",
    "yiisoft/yii2-jui": "*",
    "DsXack/yii2-underscore": "*",
    "2amigos/yii2-editable-widget": "*",
    "warrence/yii2-kartikgii": "*"
},
"require-dev": {
    "yiisoft/yii2-codeception": "*",
    "yiisoft/yii2-debug": "*"
},

推荐答案

这里 解释了为什么会发生这种情况:

Here is an explaination of why this happened:

我认为这又是 Composer 依赖解析器做了意想不到的事情:

I think this is again the composer dependency resolver doing unexpected things:

  • 您的 composer.json 中需要 yiisoft/yii2 但没有安装 composer 资源插件.
  • 然后依赖解析器没有找到带有供应商 bower-asset 的包,所以它会寻找没有冲突的 yiisoft/yii2 的其他版本
  • 结果是安装yii2测试版即可
  • you require yiisoft/yii2 in your composer.json but do not have the composer asset plugin installed.
  • then the dependency resolver does not find packages with vendor bower-asset so it looks for other versions of yiisoft/yii2 that do not have conflict
  • The result is to install the beta version of yii2 to be installed

已经提到的正确解决方案是安装 作曲家资产插件:

The correct solution as already mentioned is to install the composer-asset-plugin:

php composer.phar global require "fxp/composer-asset-plugin:1.0.*@dev"

这篇关于Yii2 错误:yiiaseUnknownMethodException:调用未知方法:yiiwebUrlManager::addRules()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆