通配锂路由

Mew*_*wel 1 lithium

我想路由这样的东西:http: //myapp.com/mycontroller/ ...?x = ...

mycontroller之后的所有东西都是未知的.我不知道路径,我不知道任何参数.路由后,路径和参数应显示为一个变量.

// route in routes.php
Router::connect('/mycontroller/*', 'Mycontroller::index');

// the index function of Mycontroller class
public function index($pathWithParameters) {
    print_r($pathWithParameters); // something like: 'hello/world?name=mewel&id=123
}
Run Code Online (Sandbox Code Playgroud)

这可能吗?

Meh*_* B. 6

Router::connect('/mycontroller/{:args}', 'Mycontroller::index');
Run Code Online (Sandbox Code Playgroud)

然后,从你的控制器,检查$this->request->params,和$this->request->query

注意:您也可以func_get_args()在控制器中使用.看一下默认的PagesController作为示例