R
R
Ruslan Ibragimov2016-02-13 11:07:22
Yii
Ruslan Ibragimov, 2016-02-13 11:07:22

What is the best way to collect UrlRules from a module?

Good afternoon friends, I started to transfer the project from yii 1 to 2, I have $urlRules = [] in each module, in the first version I scanned all the modules and merged all the rules into one array, in the second one I need to do the same or there is already a ready-made solution in Yii itself??
and the second question is if the url ends with a slash / then it gives 404, where is it set up?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Ibragimov, 2016-02-13
@RuslanIbragimov

I already found a solution for the first question.

use yii\base\BootstrapInterface;
class Module extends \yii\base\Module implements BootstrapInterface{
    public function bootstrap($app)
    {
        $app->getUrlManager()->addRules($this->urlRules, false);
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question