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.

Router: How to force matching rule to be last rule (stop looking after that)

I have following rules on my routing

$router->add('/profile/{name}', array( 'module' => 'frontend', 'namespace' => 'www\Frontend\Controllers\', 'controller' => 'profile', 'action' => 'view', "name" => 1, ));

This works fine, however i want to match following routes to differetn action how do i do that ?

$router->add('/profile/edit', array( 'module' => 'frontend', 'namespace' => 'xxx\Frontend\Controllers\', 'controller' => 'profile', 'action' => 'edit', "name" => 1, ));


Since you can add many routes as you need using the add() method, the order in which routes are added indicate their relevance, latest routes added have more relevance than first added. Internally, all defined routes are traversed in reverse order until Phalcon\Mvc\Router finds the one that matches the given URI and processes it, while ignoring the rest.

I think this means if you put your /profile/edit rule below your generic /profile/{name} rule, then it will be encountered and routed first.