We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to use routing to get parameter

I want to get the "q" parameter value for urls like this:

https://api.domain.com/artist?callback=jQuery1710976531726308167_1400000891029&q=thanh&_=1400000895743

How to do that using routing in Phalcon? I try this but not working:

$app->get("/artist?callback={callback:(.*)}&q={q:(.*)}&_={_:(.*)}", function ($q) {
    //my logic code
}

Inside a controller, you can use:

$q_parameter = $this->request->getQuery('q');


21.0k
Accepted
answer
edited May '14

Thank you, quasipickle. I'm not using controller. I'm using micro application. So I have the solution from stackoverflow:

$app->get("/artist", function () use($app) {
    $q = $app->request->getQuery('q');
    //my logic code
}