How to match traditional routing

see the route “http://abc.com/check/tel?value=15767676767”

I want to match it, how can I go to deal with this traditional url?

$router->addGet('/check/(tel|nickname|email)/:param', array(
    'module' => 'index',
    'controller' => 'public',
    'action'     => 'check',
    'checktype'     => 1,
    'param'        =>  2
));
$router->addGet('/check/(tel|nickname|email)', array(
    'module' => 'index',
    'controller' => 'public',
    'action'     => 'check',
    'checktype'     => 1   
));


5.1k
edited Sep '15

I was curious about it and prepared earlier some piece of code because i wrongly understood your question. I thought you want to have that query captured somehow into params. Let me place the code anyway because it is useful for me and i don't want to lose it (it is not used in my code anywhere). Some variables should be escaped and i didn't use $request->getQuery rather than using $_GET variable. The code below causes url host//check/tel/asdf/wer?test=10&test2=20 To produce

Array ( [0] => asdf [1] => wer [2] => test [3] => 10 [4] => test2 [5] => 20 )

        $router->add("/check/(tel|nickname|email)/{params:.*}", array(
            'controller' => 'index',
            'action'     => 'index',
            'params' => 2
        ))->convert('params', function ($params) {

            $a=$_GET;
            unset($a["_url"]);
            $slashedString="";
            foreach ($a as $key => $value) {
                $slashedString.="/$key/$value";                                
            }

            return $params.$slashedString;

    });;

And don't forget that only the standard "params" named property is converted from string into array automatically. Additionally you might control over the action params https://docs.phalconphp.com/en/latest/reference/dispatching.html#preparing-parameters This is quite interesting to read. For example the foregoing link might help when you have 100 routes and you want change something for them all in one place.