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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵