K
K
Khurshed Abdujalil2018-01-30 20:29:47
Yii
Khurshed Abdujalil, 2018-01-30 20:29:47

How to fix yii2 error - UrlRule::pattern must be set.?

I tried to upload the project to the server, then I got the error
Invalid Configuration - yii\base\InvalidConfigException
UrlRule::pattern must be set.
locally everything works correctly, swears at the rules

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' => true,
            'rules' => [
                [
                    'class' => 'frontend\components\UrlRouterFront'
                ],
                '<controller>/<action>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>/*' => '<controller>/<action>',
                '/' => 'site/index',
            ],
        ],

namely, 'class' => 'frontend\components\UrlRouterFront'
didn't have such a problem with other projects, can you tell me how to fix it?
How to set this pattern? or how to do without it? after all locally everything works...
upd.
added to this class
public function init()
    {
        $this->pattern = 'test';
        $this->route = 'test';
        parent::init();
    }

It worked, but locally and without it, what's the trick?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-01-31
@webinar

locally everything works correctly,

because the errors are turned off apparently
I understand
[
    'class' => 'frontend\components\UrlRouterFront'
],

should not be in the rules, but on the same level with it, although xs what do you have in it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question