1
votes

I've just created a new controller as i usually do but, this time I got a problem with routing.

In profiler route matches but I can't reach them and get No route found for "GET /prezzi/listino"

Controller

<?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;

class PricesController extends Controller {
    /**
     * @Route("/prezzi/listino", name="prezzi_listino")
     */
    public function pricesListAction()
    {
        $list = $this->getDoctrine()->getRepository('AppBundle:Prices')->findAll();

        return $this->render('prices/list.html.twig', [
            'items' => $list
        ]);
    }
}

Debug Router

$ php bin/console debug:router
 ----------------------------------- ---------- -------- ------ ------------------------------------------------------- 
  Name                                Method     Scheme   Host   Path                                                   
 ----------------------------------- ---------- -------- ------ ------------------------------------------------------- 
[..]
  prezzi_listino                      ANY        ANY      ANY    /prezzi/listino                                        
[..]
 ----------------------------------- ---------- -------- ------ ------------------------------------------------------- 

Router Match

$ php bin/console router:match --method GET /prezzi/listino



 [OK] Route "prezzi_listino" matches                                                                                    


+--------------+---------------------------------------------------------+
| Property     | Value                                                   |
+--------------+---------------------------------------------------------+
| Route Name   | prezzi_listino                                          |
| Path         | /prezzi/listino                                         |
| Path Regex   | #^/prezzi/listino$#sD                                   |
| Host         | ANY                                                     |
| Host Regex   |                                                         |
| Scheme       | ANY                                                     |
| Method       | ANY                                                     |
| Requirements | NO CUSTOM                                               |
| Class        | Symfony\Component\Routing\Route                         |
| Defaults     | _controller: AppBundle:Prices:pricesList                |
| Options      | compiler_class: Symfony\Component\Routing\RouteCompiler |
| Callable     | AppBundle\Controller\PricesController::pricesListAction |
+--------------+---------------------------------------------------------+

Any ideas of where is the error? I think is a distraction cause I haven't see this problem.

1
That's weird. I can't see the issue :\ Are you sure you're visiting the right url? Moreover, are you generating the route or are you hitting it directly by wrinting in the url bar?DonCallisto
I really can't understand, the url is right (I've tried to copy/paste the url form route annotation to make sure), I've tried first writing the controller by hand and then deleted and generated using generate:controller. Tried first to generate an url using {{ url('prezzi_listino') }} and when I realize that don't work I've tried putting directly in url bar. That's so strange and impossible in real cause I've follow the same procedure as normally do.andreaem
What error {{ url('prezzi_listino') }} gives you back?DonCallisto
Sorry An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "prezzi_listino" as such route does not exist.").andreaem

1 Answers

2
votes

Since I've tried to add the route in another controller that actually work, and doesn't seems to work, I've just come to the conclusion that I can't add any new route so it's meaning that is a cache error.

Running php bin/console cache:clear --env=dev --no-warmup solve the problem.