Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3dmaxpayne opened this issue Sep 17, 2014 · 111 comments
Closed

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

3dmaxpayne opened this issue Sep 17, 2014 · 111 comments
Labels
Milestone

Comments

@3dmaxpayne
Copy link

Hello! Thank you for your work!
I have updated today by composer and found this error:

http://awesomescreenshot.com/0ff3hzs143

Do you have removed this method anywhere except debug mode?

@ITGodzilla
Copy link
Contributor

I also encountered this problem.

@huaiguoguo
Copy link

I also encountered this problem.
强哥啊,我也遇到这个问题了,一更新,就出现这个情况。。。。啥时候能解决啊。。

@zqtsx
Copy link

zqtsx commented Sep 17, 2014

我今天上午刚换的YII2.0 刚装上去就是这个提示
Unknown Method – yii\base\UnknownMethodException
Calling unknown method: yii\web\UrlManager::addRules()

@zqtsx
Copy link

zqtsx commented Sep 17, 2014

上面是完成 错误提示

@pahanini
Copy link

Also affects to me

@zqtsx
Copy link

zqtsx commented Sep 17, 2014

you too ?

@githubjeka
Copy link
Contributor

composer install --dev

@huaiguoguo
Copy link

composer install --dev 能行吗,我们这是更新啊。。。

@githubjeka
Copy link
Contributor

чё ? 。。。。。。。。。。。。

@zqtsx
Copy link

zqtsx commented Sep 17, 2014

composer install --dev 这玩意不行啊

@zqtsx
Copy link

zqtsx commented Sep 17, 2014

“composer install --dev ” is don't ok.

@aquy
Copy link
Contributor

aquy commented Sep 17, 2014

I have the same problem

@githubjeka
Copy link
Contributor

The whole world has such a problem. So there is no report;)

@zqtsx
Copy link

zqtsx commented Sep 17, 2014

you can speaking china language ? who can help me kill this bug?

@huaiguoguo
Copy link

都是中国人,为什么都不说中文,说英文很洋气么?

@githubjeka
Copy link
Contributor

I still adapts to the c234359
See extra ..

@bryglen
Copy link

bryglen commented Sep 17, 2014

this thing kills me as well.. it was pulling some previous version

@githubjeka
Copy link
Contributor

Yes it is

Add to composer.json

 "extra": {
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    }

And run
http://i.imgur.com/h3u1sqX.jpg

@zqtsx
Copy link

zqtsx commented Sep 17, 2014

楼上的方法也不行啊……

@githubjeka
Copy link
Contributor

Google translator don't understand you ^_^

@mousemckill
Copy link

Почему требует логин и пароль?

@zqtsx
Copy link

zqtsx commented Sep 17, 2014

按照你的办法也添加了那段代码,还是不行啊

@githubjeka
Copy link
Contributor

@mousemckill потому, что предоставляются права доступа composer для работы с api GITHUB

Посмотреть для кого, что доступно можно по адресу https://github.com/settings/applications

@bryglen
Copy link

bryglen commented Sep 17, 2014

guys. english please since this is world issue :)

@githubjeka
Copy link
Contributor

@bryglen if something is not by English then it is offtopic. :)

@huaiguoguo
Copy link

stop!!!!!!!!!!!!!!!!!!! please stop talk this problom of english.....ok?

@githubjeka
Copy link
Contributor

NOT OK! My solution help someone?

@bryglen
Copy link

bryglen commented Sep 17, 2014

I still get sme error @githubjeka

@bayusuwarninghadi
Copy link

Now, how to register js/css file?

use yii\web\JqueryAsset;
$this->registerJsFile(Yii::$app->getHomeUrl().'js/docs.min.js',[JqueryAsset::className()]);

-->

<script src="/js/docs.min.js" 0="yii\web\JqueryAsset"></script>
<script src="/assets/2944290e/jquery.js"></script>

script generated before jquery

@githubjeka
Copy link
Contributor

Use

use yii\web\JqueryAsset;
$this->registerJsFile(
    Yii::$app->getHomeUrl().'js/docs.min.js',
    [
        'depends'=>JqueryAsset::className()
    ]
);

The current issue nothing to do with your code

@3dmaxpayne
Copy link
Author

But guys, I still don't understand. You use this code in yii\debug\Module

$app->getUrlManager()->addRules([
$this->id => $this->id,
$this->id . '/controller:w+/action:w+' => $this->id . '//',
], false);

But I have not find any declaration of this method: addRules. So, where is declaration of it?

@githubjeka
Copy link
Contributor

Current code https://github.com/yiisoft/yii2/blob/master/framework/web/UrlManager.php#L173

Beta code - https://github.com/yiisoft/yii2/blob/2.0.0-beta/framework/web/UrlManager.php hasn't addRules. Hence the error.

You have beta code. Update your code by #5060 (comment)

@hoksilato
Copy link
Contributor

@githubjeka I followed your instruction and get error like below.

yii2-beta

I also tried to create new fresh project and it always got stuck at "Reading bower.json of bower-assets/requirejs" and then killed the process.

Can you help me? Thanks.

P/S: I'm using Cygwin + Windows 8.1 + Vagrant CentOS 6.5

@githubjeka
Copy link
Contributor

See #5083 (comment)

@hoksilato
Copy link
Contributor

Thanks @githubjeka

@Shybko
Copy link
Contributor

Shybko commented Sep 19, 2014

I'm trying code from this page http://www.yiiframework.com/doc-2.0/guide-start-installation.html for installation Yii2
Using this code
composer global require "fxp/composer-asset-plugin:1.0.*@dev"
then try this
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
and this
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic
And finally get this result
composer error
How it fixed? :(

@githubjeka
Copy link
Contributor

Read #5060 (comment)

@stratigos
Copy link

Went on vacation for 2 weeks and came back to this. Spent the morning resolving the original issue, and then the issue(s) Shybko had. Was able to resolve by adding bower-asset/jquery etc to my composer.json.

@geekwho-eth
Copy link

You must updtae composer to lastes version.
composer self-update
and then do
#5060 (comment)
work fine.

@Shybko
Copy link
Contributor

Shybko commented Sep 23, 2014

This #5107 (comment) solution helped me

@flutterbest
Copy link

http://www.cnsecer.com/6054.html 不要谢我! i am leifeng!

@gephaest
Copy link
Contributor

I have same problem, my console:

composer self-update
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic

Add to composer.json:

"extra": {
    "asset-installer-paths": {
        "npm-asset-library": "vendor/npm",
        "bower-asset-library": "vendor/bower"
    }
}

Console:

composer global require "fxp/composer-asset-plugin:1.0.*@dev"
composer update --dev --dry-run

And I have error:
Calling unknown method: yii\web\UrlManager::addRules().
In UrlManager.php addRules doesn't exist.

My composer.json: https://gist.github.com/gephaest/7e973935161edd5869b7

@samdark
Copy link
Member

samdark commented Sep 29, 2014

First fxp/composer-asset-plugin then update.

@gephaest
Copy link
Contributor

@samdark I did so, but yii2 don't running

@githubjeka
Copy link
Contributor

Read guide! what is it 1.0.*@dev" ?

@hoksilato
Copy link
Contributor

@gephaest you should use composer global require "fxp/composer-asset-plugin:1.0.0-beta2" instead of composer global require "fxp/composer-asset-plugin:1.0.*@dev".

Delete your vendor directory and composer.lock.

Then composer install --prefer-dist.

@gephaest
Copy link
Contributor

@hoksilato thanks. I'm new with Composer. I was following by this instructions: #5060 (comment) :)

Your method works fine. Thanks!

@githubjeka
Copy link
Contributor

@samdark please lock conversation on this issue and add link to latest guide of installation. :)

@githubjeka
Copy link
Contributor

Not? Well, okay.

@yiisoft yiisoft locked and limited conversation to collaborators Sep 29, 2014
@cebe
Copy link
Member

cebe commented Sep 29, 2014

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests