I am running a fuelphp app with a route that looks like this:
'lastname/:lastname/firstname/:firstname'=> '(@api)/mycontroller/my_method/$2/$1',
And then I have a method on my controller like this:
public function get_my_method($firstname, $lastname);
Unfortunately, what happens is the $firstname
variable contains the :lastname
passed in from the route, and the the $lastname
variable contains the :firstname
passed in from the route.
I've tried switching around the $2
and $1
from the routes file.
I'd like to keep the endpoint url untouched - I'd just like to reverse the argument order coming in to the controller method.
Anyone know how to accomplish this?
You need to wrap the segments in brackets to capture them rather than using named parameters.
'lastname/(:segment)/firstname/(:segment)' => '(@api)/mycontroller/my_method/$2/$1'
The alternative is to use $this->param('firstname')
, etc, in your controller rather than having them passed as arguments to the action function.