We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Dispatcher getParams() ignores blank value

regarding documentation I've added parameter handler to my dispatcher for hanling URLs like this: https://example.com/controller/key1/value1/key2/value

but when a key has a blnak value dispatcher->getParams() give invalid answer! see example:

URL: https://example.com/controller/action/key1/value1/key2//key3/value3 // <- key2 has blank value
// expected [ key1:value1, key2:null, key3:value3 ]
// returns  [ key1:value1, key2:key3 ]    <- why bypassed blank value!!!
edited Mar '15

Sorry, but i understand if you send parameters through dispatcher you must do it this way

//action controller.php
public function indexAction()
        "action" => "other",
        "params" => array("one" => 1, "two" => 2)

public function otherAction()
    $paramOne = $this->dispatcher->getParam("one");

When you get from url use $this->request->getQuery or getGet().

Thanks, but this is not my question. I know the differences between $this->request->getQuery() & $this->request->getPost() & $this->request->get() and $this->dispatcher->getParam()

my question is why /key1/value1/key2//key3/value3 ignored by dispatcher. (please attention to RED part)

What is the key2 value from the url?

edited Mar '15

Ok well, in the url phalcon not take key and value, php https://myurl/controller/action/value1/value2/value3/value4, so if you put two slashes php // phalcon take that as just one slashes / the best way to get

public function theactionAction($key1, $key2, $key3, $key4)
    var_dump($key1, $key2, $key3, $key4);

//This print : string(10) "value1" string(8) "value2" string(4) "value3" string(5) "value4"

So, if you send: https://myurl/controller/action/value1/value2//value3/value4, will do the same... For this reason phalcon not take your url.

edited Mar '15

Thanks @julianmolina but this solution theactionAction($key1, $key2, $key3, $key4) requires a custom route.

In fact I'm looking for a global solution that is not custom route dependent.

Phalcon reduces double slashes to single slashes.

A key/value relationship like what you have in your URL is different than how Phalcon handles routes by default - I'm almost positive this isn't a bug. I think your best bet is to not have a blank value, but instead have a value that can be interpreted as blank, like a dash, or colon or something. Failing that, what if you put your key/value pairs in GET variables? This is what they're supposed to be used for.