Routing - making route segments optional

Hi all,

I have posted this question on StackOverflow:

http://stackoverflow.com/questions/17929493/phalcon-routing-making-route-segments-optional

Any help will be appreciated. It's unclear from the docs how one would make route segments optional. I did not have the same problem with Zend Framework routes, so assumed Phalcon would do something similar

Thank you, Temuri



30.7k

@doit76

Thanks. But that suggestion seems to be more of a workaround and does not work as I expect.

I've defined route as: /admin[/]?{controller:[a-z]}[/]?{action:[a-z]}

That matched /admin/foo/bar just fine.

However, /admin/foo populated 'controller' with 'foo' and 'action' was an empty string (not a default 'index').

I've looked around some more and it does seem to be possible to have segments optional.

It's a pity, as that significantly increases number of routes I have to define.

Temuri