doubi1931 2018-09-18 14:38
浏览 143
已采纳

Symfony 3.4:路由匹配,但在网址中找不到路由

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条回答 默认 最新

  • duanjia1870 2018-09-18 20:57
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题
  • ¥15 Selenium+docker Chrome不能运行
  • ¥15 mac电脑,安装charles后无法正常抓包
  • ¥18 visio打开文件一直显示文件未找到
  • ¥15 请教一下,openwrt如何让同一usb储存设备拔插后设备符号不变?
  • ¥50 使用quartz框架进行分布式任务定时调度,启动了两个实例,但是只有一个实例参与调度,另外一个实例没有参与调度,不知道是为什么?请各位帮助看一下原因!!