Cant use tockens and extrapattern together for REST services in Yii2

和自甴很熟 提交于 2019-12-08 07:17:00

问题


Yii2 REST query

I found this for using custom action in the controller for that i added the extrapattern mentioned in the above link

And its working fine when we search .but cant use the normal actions for the controller

'urlManager' => [
        'enablePrettyUrl' => true,
        'enableStrictParsing' => true,
        'showScriptName' => false,
        'rules' => [
            [
                'class' => 'yii\rest\UrlRule', 
                'controller' => 'v1/country',
                'extraPatterns' => [
                    'GET search' => 'search'
                    ],
                'tokens' => [
                    '{id}' => '<id:\\w+>'
                ]

            ]
        ],        
    ]

Regards


回答1:


Thanks all

this solved my problem after lots of trying..

          'rules' => [
            [
                'class' => 'yii\rest\UrlRule', 
                'controller' => 'v1/country',
                'extraPatterns' => [
                    'GET search' => 'search'
                    ],                 
            ],
            [
                'class' => 'yii\rest\UrlRule', 
                'controller' => 'v1/country',
                'tokens' => [
                    '{id}' => '<id:\\w+>'
                ]

            ],

        ], 


来源:https://stackoverflow.com/questions/27167458/cant-use-tockens-and-extrapattern-together-for-rest-services-in-yii2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!