Get (uri-)parameters with phalcon

Hi,

I need to get all parameters from an URL like this one

http://localhost/slipbox/uniques/list/keywords?title=K

I can get the controller with $this->dispatcher->getControllerName() When I use $this->dispatcher->getParams(), I only get a one-value-array with [0] => 'keywords'.

My Problem is, that the amount and the names of the parameters are variable.

What is the right way? Thanks a lot! Aljoscha

edited Feb '15
$this->dispatcher->getParams()

Would get you the /:params bit from your route, not the querystring (?title=K).

Try using:

$this->request->getQuery('title');

http://docs.phalconphp.com/en/master/api/Phalcon_Http_Request.html

If you call getQuery() without specifying a key, you'll get the full $_GET array which is what you want I think?

$_GET is still set. Why not just access it directly? Yes there is a Phalcon way of doing it with $this->request->getQuery() but unless you need the filtering/validation that goes along with it - using $_GET is simpler.

True. I just thought I'd mention it but avoiding extra function calls is always a good thing.