Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to use routing to get parameter

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

http://api.domain.com/artist?callback=jQuery1710976531726308167%51400000891029&q=thanh&%5=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');


11.8k
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
}