![](/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.