【发布时间】:2017-04-10 20:46:25
【问题描述】:
如标题所示,如果我尝试访问以下 URL,则会遇到该问题:
http://app.local/sf/customer-first-progam-level
这就是我所拥有的:
-
app/routing.yml
quote: resource: "@QuoteBundle/Controller/" type: annotation prefix: /sf -
QuoteBundle/Controller/CustomerFirstProgramLevelController.php
<?php namespace QuoteBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; /** * @Route("customer-first-program-level") */ class CustomerFirstProgramLevelController extends Controller { use GridBuilder; /** * @Route("/", name="customer_first_program_level_index") * @Method({"GET", "POST"}) * @param Request $request * * @return \Symfony\Component\HttpFoundation\Response * @throws \LogicException */ public function indexAction(Request $request) { ... } }
这是我尝试过但没有成功的方法:
- 清除 prod 和 dev 的缓存
- 将路线名称更改为其他名称
如果我调试router,我会得到以下结果:
$ symfony_console debug:router
------------------------------------ ---------- -------- ------ --------------------------------------------
Name Method Scheme Host Path
------------------------------------ ---------- -------- ------ --------------------------------------------
customer_index GET|POST ANY ANY /sf/customer/
customer_first_program_level_index GET|POST ANY ANY /sf/customer-first-program-level/
discount_index GET|POST ANY ANY /sf/discount/
....
------------------------------------ ---------- -------- ------ --------------------------------------------
我正在使用 Symfony 3.2.7。有任何想法吗?我没有他们
【问题讨论】:
-
试试app.local/sf/customer-first-progam-level,最后加上一个斜线。如果您希望网址末尾没有斜杠,请将注释中的“/”更改为“”
-
我同意@FrankB。您的休息路线不完整
-
@FrankB 这似乎不是问题,我已经尝试添加斜杠并将其从路由中删除,但仍然无法正常工作,这很奇怪,我所有的控制器都具有相同的结构没有一个,但这个失败了
-
问题在于
progam中缺少r。我投票赞成关闭这个问题,因为它是一个错字。 -
有时很简单,您看不到问题:-) 感谢您的回复
标签: php symfony symfony-routing symfony-3.2