Php 未找到“的路由”;获取/索引“;生成Symfony控制器时

Php 未找到“的路由”;获取/索引“;生成Symfony控制器时,php,symfony,Php,Symfony,我正在使用generate:controller在我的Symfony 3应用程序中创建一个新的控制器。但是路线没有找到 这是命令的输入/输出 First, you need to give the controller name you want to generate. You must use the shortcut notation like AcmeBlogBundle:Post Controller name: ApplicationSonataPageBundle:Page D

我正在使用
generate:controller
在我的Symfony 3应用程序中创建一个新的控制器。但是路线没有找到

这是命令的输入/输出

First, you need to give the controller name you want to generate.
You must use the shortcut notation like AcmeBlogBundle:Post

Controller name: ApplicationSonataPageBundle:Page

Determine the format to use for the routing.

Routing format (php, xml, yml, annotation) [annotation]: yml

Determine the format to use for templating.

Template format (twig, php) [twig]:

Instead of starting with a blank controller, you can add some actions now. An action
is a PHP function or method that executes, for example, when a given route is matched.
Actions should be suffixed by Action.


New action name (press <return> to stop adding actions): IndexAction
Action route [/Index]:
Template name (optional) [ApplicationSonataPageBundle:Page:index.html.twig]:

New action name (press <return> to stop adding actions):


  Summary before generation


You are going to generate a "ApplicationSonataPageBundle:Page" controller
using the "yml" format for the routing and the "twig" format
for templating
Do you confirm generation [yes]?
。。。这不是所谓的。我在浏览器中收到以下错误:

未找到“获取/索引”的路由

在看到我的行动之前,我还需要执行其他步骤吗?


我所尝试的:到目前为止,我尝试了所有其他类型的路由(xml、php、yml),但都没有成功

值得一提的是:我最终只是放弃并复制了以下内容:

_index:
    path:     /Index
    defaults: { _controller: ApplicationSonataPageBundle:Page:Index }

。。。从生成的yml文件到我的应用程序的主routing.yml文件

有几件事需要检查:

确保您的路线包含在
config/routes.yml



还要确保您的包已加载到内核中:
app/AppKernel.php

我注意到另一件事,你的行动/路线是大写的。我不确定这是否会产生影响,但通常的做法是
camelCasing
,因此您将使用
indexAction
而不是
indexAction


还有一个显示可用路由的命令,我相信它类似于
php-bin/console-routes:debug
如果您运行
php-bin/console
它应该显示可用的命令

是的,您需要确保主路由文件包括您的路由。不过,有很多方法可以包含路线。您包括一条路线。您还应该能够包括位于所述捆绑包中的整个捆绑包和routing.yml文件。但是你需要确保它们在主路由文件中被调用。我在我的答案中添加了另一个链接,它显示了加载路由的不同方式。检查此链接,它将显示如何包含外部.yml路由文件
_index:
    path:     /Index
    defaults: { _controller: ApplicationSonataPageBundle:Page:Index }