S
S
Sergey Beloventsev2017-10-04 09:33:43
Yii
Sergey Beloventsev, 2017-10-04 09:33:43

Why does this error "Setting unknown property: yii\web\UrlRule" occur?

I created the api folder in it in config/main.php, this rule
created a module in it and in the module the BonusController controller in it actionsGetBonus

'urlManager' => [
            'enablePrettyUrl' => true,
            'enableStrictParsing' => true,
            'showScriptName' => false,
            'rules' => [
                   [
                        'class' => 'yii\rest\UrlRule',
                        'controller' => ['v1/bonus'],
                        'extraPatterns' => [
                            'GET bonus' => 'get-bonus',
                        ]
                    ]
                ],
            ],

I try to find it at site.loc/api/web/v1/bonuses/get-bonus?id=1 and I get an error Setting unknown property: yii\web\UrlRule what am I doing wrong

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Beloventsev, 2017-10-04
@Sergalas

the error was that I called an array in an array like this for me

'rules' => [
                   [
                        'class' => 'yii\rest\UrlRule',
                        'controller' => ['v1/bonus'],
                        'extraPatterns' => [
                            'GET bonus' => 'get-bonus',
                        ]
                    ]
                ],

and it should have been like this
'rules' => [
                   
                        'class' => 'yii\rest\UrlRule',
                        'controller' => ['v1/bonus'],
                        'extraPatterns' => [
                            'GET bonus' => 'get-bonus',
                        ]
                    
                ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question