S
S
search742015-08-17 08:18:56
Yii
search74, 2015-08-17 08:18:56

Own method in a controller in a restful application?

Hello everyone, I made a restful application following the official doc .
Tell me, please, how and where can I define a new method "actionLogin" so that it is executed, for example, with such a request - "GET /api/users/login"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
search74, 2015-08-17
@search74

I seem to have figured it out:

'urlManager' => [
      'enablePrettyUrl' => true,
//            'enableStrictParsing' => true,
            'showScriptName' => false,
            // here is your backend URL rules
      'rules' => [
                [
                    'class' => 'yii\rest\UrlRule',
          'controller' => ['v1/country', 'v1/menu'],
                    'tokens' => [
                        '{id}' => '<id:\\w+>',
                    ],
                ],
        [
          'class' => 'yii\rest\UrlRule',
          'controller' => ['v1/user'],
          'extraPatterns' => [
            'GET login' => 'login',
          ],
        ]
            ],
        ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question