【发布时间】:2021-07-25 02:10:44
【问题描述】:
我想在 Symfony 4.4 路由中用“-”替换空格 (%20) 并删除我的 {slug} 的第一个大写字母。
例如:
RecipeController.php
/**
* @Route("/receta/{title}", name="recipe_show", methods={"GET"})
*/
public function show(Recipe $recipe): Response
{
return $this->render('recipe/show/show.html.twig', [
'recipe' => $recipe,
]);
}
现在我的路线显示了。
https://localhost:8000/receta/Pollo%20agridulce%20chino
但我想展示
https://localhost:8000/receta/pollo-agridulce-chino
在我的 BD 中,我保存“Pollo agridulce chino”
我该怎么做?
【问题讨论】:
标签: symfony routes symfony4 space symfony-4.4