We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Route with many parameters

Hi the syntax for the route is $router->add( "/admin/:controller/a/:action/:params", [ "controller" => 1, "action" => 2, "params" => 3, ] );

what if I have many parameters lets say I want a post($id,$name,$surname), can someone give me an example of route that can take this post and being reusable for a similar post but with different attributes like post($id,$accountName,$type). Thanks in advance.

Hey, you have two options:

1) Define all possible routes like:


2) Or just use the :params parameter at the end of the route:

// Definition

// Call it like:
$params = [123, 456, 789];
$this->url->get(['for' => 'blabla', 'params' => implode('/', $params)]);

// Output

// Get params values in controller

edited Dec '16