![](/img/trans.png)
[英]How do I use the Symfony DomCrawler with Laravel's subdomain routing?
[英]symfony - how to do routing
我需要 symfony 的帮助,如何进行路由并将页面添加到完成的项目中,这是我添加新路由的地方:src/BlogBundle/Resources/config/routing_news.yml 这里是代码:
reset:
path: / reset_mail
defaults: {_controller: BlogBundle: Page: reset_mail}
然后我在控制器中添加:src/BlogBundle/Controller/PageController.php 代码:
public function reset_mail(Request $request)
{
$pageRepository = $this->getDoctrine()->getRepository('AdminBundle: reset_mail');
$page = $pageRepository->findOneBy([
'path' => 'page / reset_mail'
]);
return $this->render('BlogBundle: Page: reset.html.twig', [
'title' => $page->getTitle()
]);
}
好吧,我在 src/BlogBundle/Resources/views/Page 中创建了文件:reset.html.twig。 所以这就是我做错的地方,因为当我去这个/页面/reset_mail 时,什么也没有发生。 我做错了什么,如何做对?
您应该为路由使用注释。
https://symfony.com/doc/current/routing.html
这是一个很好的做法( https://symfony.com/doc/current/best_practices.html#don-t-use-annotations-to-configure-the-controller-template )。
使用注释真的很简单,而且更好。
希望这会很有用。
干杯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.