yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

Calling unknown method: yii\web\UrlManager::addRules() #4141

Closed eukos closed 10 years ago

eukos commented 10 years ago

I create new project based on yii2 using composer.

composer.json content:

{
    "minimum-stability": "dev",
    "require": {
        "yiisoft/yii2": "2.*"
    },
    "require-dev": {
        "yiisoft/yii2-debug": "*",
        "yiisoft/yii2-gii": "*"
    }
}

As in the app-basic I added the following lines to the config file:

if (YII_ENV_DEV) {
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = 'yii\debug\Module';
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = 'yii\gii\Module';
}

And now, when I opens any page I got the following error:

Calling unknown method: yii\web\UrlManager::addRules() Stacktrace:

  1. in /home/vhosts/host/vendor/yiisoft/yii2/base/Component.php at line 285
  2. in /home/vhosts/host/vendor/yiisoft/yii2-debug/Module.php – yii\base\Component::__call() at line 125
  3. in /home/vhosts/host/vendor/yiisoft/yii2-debug/Module.php – yii\web\UrlManager::addRules() at line 125

If I comment out lines in config related to debug module, then the same error appears but with the different stacktrace:

  1. in /home/vhosts/host/vendor/yiisoft/yii2/base/Component.php at line 285
  2. in /home/vhosts/host/vendor/yiisoft/yii2-gii/Module.php – yii\base\Component::__call() at line 91
  3. in /home/vhosts/host/vendor/yiisoft/yii2-gii/Module.php – yii\web\UrlManager::addRules() at line 91
klimov-paul commented 10 years ago

Try to update your composer.json into following way:

"require": {
        "yiisoft/yii2": "*"
    },
eukos commented 10 years ago

It helps! Thank you!

lisiy50 commented 10 years ago

same promlem, but "require": { "yiisoft/yii2": "*" }, does not help

ViolentStorm commented 10 years ago

Install via composer at now and have same problem

winogradow commented 10 years ago

same problem and 1 more promblem: ReflectionException

Class yii\rbac\PhpManager does not exist

RdeWilde commented 10 years ago

Same problem "minimum-stability": "dev", ... "yiisoft/yii2": "*",

RdeWilde commented 10 years ago

http://stackoverflow.com/questions/25884038/yii2-error-yii-base-unknownmethodexception-calling-unknown-method-yii-web-url Post from ricardgf

And I had to configure my Github credentials because of API rate limit: composer config http-basic.github.com username password

Those two together, fixed it for me