I am having this error:
Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException: No route found for "GET /blog" (from " http://localhost:8000/produits ")
I added the annotation @Route in the method in my controller (like I saw in other website):
/**
* @Route("/blog", name="article.index")
* @return Response
* */
public function index():Response
{
return $this->render("blog/article.html.twig", [
"current_menu" => 'articles'
]);
}
I tried to add methods={"GET","HEAD"} in @Route but I have the same error
How do I solve this problem?
This one worked for me (adding / to the end of route path):
/**
* @Route("/blog/", name="article.index")
* @return Response
* */
public function index():Response
{
return $this->render("blog/article.html.twig", [
"current_menu" => 'articles'
]);
}
You will also at least need use Symfony\\Component\\Routing\\Annotation\\Route;
at the start of the file (among the other 'use' lines), Some framework setup for Route annotations could also need to be enabled. Also, how does blog/article.html.twig refer to the route or path?
A freshly installed Symfony 4 instance will need composer require doctrine/annotations package, unless its already been installed by some other package.
https://symfony.com/doc/current/routing.html#creating-routes has more details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.