亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

yii2 - (php layer only) How YAF is compatible with YII's [hump action becomes minus sign] url routing rules
世界只因有你
世界只因有你 2017-05-19 10:08:38
0
1
786

Background description:
1. In yii, there are the following Controller

class PayController extends Controller
{
    public function actionIosCallback()
    {
        echo 'hello yii';
    }
}
訪(fǎng)問(wèn)www.XXX.com/pay/ios-callback,則頁(yè)面顯示hello yii

2. In yaf, there are the following Controller

class PayController extends Yaf_Controller_Abstract{
    public function actionIosCallback()
    {
        echo 'hello yaf';
    }
}
訪(fǎng)問(wèn)www.XXX.com/pay/iosCallback,則頁(yè)面顯示hello yaf

Problem description:
3.Ask how yaf is compatible with yii and access www.XXX.com/pay/ios-callback, then the page will display hello yaf

Note: Currently, the solution that I can think of is to rewrite the URL in the Nginx layer, but I think it is not the best solution, so I only discuss the PHP layer implementation

世界只因有你
世界只因有你

reply all(1)
習(xí)慣沉默

After studying the YII source code, I finally found the rules for rewriting routing. The method is as follows

str_replace(' ', '', ucwords(str_replace('-', ' ', $action)))

The implementation method is to introduce this rule into the routerShutdown of yaf, so that the routing rules can be rewritten to achieve the purpose of displaying hello yaf on the page when accessing www.XXX.com/pay/ios-callback

public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {
$request->controller = str_replace(' ', '', ucwords(str_replace('-', ' ', $request->controller)));
$request->action = str_replace(' ', '', ucwords(str_replace('-', ' ', $request->action)));
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template