php - Symfony - how to generate url with parameters in controller -
i want generate url ../profile/firstname.lastname
but don't understand how can because want in php id user.
this controller:
$controllers ->match('profile/{firstname.lastname}/', array($this, 'profile')) ->assert('userid', '\d+') ->method('get|post') ->before(array($this, 'checklogin')) ->bind('home.profile');
you have build route
this
<route id="profile" path="/profile/{first_name}.{last_name}"> <default key="_controller">...</default> </route>
and in controller create this
$this->generateurl('profile', [ 'first_name' => 'skowron', 'last_name' => 'line' ]);
but if have 2 profiles same data give bad results. can create slug or add id
parameter route
Comments
Post a Comment