我正在尝试在控制器上添加新路由,但在使用电子邮件参数时遇到了问题:
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/foo/{email}", methods="GET")
*
* @param string $email
*
* @return JsonResponse
*/
public function fooAction(string $email) {
return JsonResponse::create('OK!');
}
似乎Symfony路由不允许.
。
我是否需要添加一些东西以使其有效?
答案 0 :(得分:1)
好吧,因为我在开发环境中,并且我使用
启动服务器php -S 127.0.0.1:8000 -t public
使用symfony / web-server-bundle工作
答案 1 :(得分:0)
尝试使用'/'
结束路线@Route(“/ foo / {email} /”,methods =“GET”)
答案 2 :(得分:0)
您需要首先对电子邮件地址进行URL编码吗?
答案 3 :(得分:0)
你应该用正则表达式解决这个问题,尝试一些like this answer
希望它有所帮助!