D
D
Dilik Pulatov2018-03-12 11:50:32
Yii
Dilik Pulatov, 2018-03-12 11:50:32

What is the easiest way to parse url in Yii2 RESTapi?

Hello!
here is the array in UrlManager config

[
          'class' => 'yii\rest\UrlRule', 
          'controller' => [
            'api/dashboard',
            'api/user',
            'api/post',
          ],
          'extraPatterns' => [
            'POST list' => 'list',
            'POST categorys' => 'categorys',
            'POST category-posts' => 'category-posts',
            'POST post' => 'post',
            'POST search' => 'search',
            'POST get-table-list' => 'get-table-list',
            'POST get-table' => 'get-table',
            'POST get-calendar' => 'get-calendar',
            'POST dictionary' => 'dictionary',
          ]
        ],

here I removed the standard actions and added my own ... everything works fine .... but extraPatterns can be made as simple as possible so that each time you do not write a new action to the array
in the UrlManager, they write something like this
'admin/<controller:\w+>/<action:[a-z\-]*>'=>'admin/<controller>/<action>'

is it possible in the API? And How?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question