Php 如何使用Symfony将参数传递给控制器?
我像这样将var argurmrnt传递给控制器Php 如何使用Symfony将参数传递给控制器?,php,symfony,controller,Php,Symfony,Controller,我像这样将var argurmrnt传递给控制器 return $this->redirect($this->generateUrl('user_profile', array('var' => $profile->getId()))); 这是我的控制器 /** * @Route("/profile", name="user_profile") * @Template() */ public fu
return $this->redirect($this->generateUrl('user_profile', array('var' => $profile->getId())));
这是我的控制器
/**
* @Route("/profile", name="user_profile")
* @Template()
*/
public function ProfileAction($var)
{
$em = $this->getDoctrine()->getEntityManager();
但我总是出错
控制器“xxxx\Controller\UserController::ProfileAction()”需要
为“$var”参数提供一个值(因为没有
默认值或,因为在此之后有一个非可选参数
一)
您忘记在路线中添加占位符,根据
/**
* @Route("/profile/{var}", name="user_profile")
* @Template()
*/
public function ProfileAction($var)
{
$em = $this->getDoctrine()->getEntityManager();