symfony 2 找不到“GET/"的路由 [英] symfony 2 No route found for "GET /"

查看:41
本文介绍了symfony 2 找不到“GET/"的路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Symfony2 返回 No route found for "GET/" 当我尝试运行 http://localhost/app_dev.php 时,但是这个url 有效:http://localhost/app_dev.php/hello/Symfony.我删除了 AcmeDemoBundle,我正在尝试从 symfony2 教程中运行一个示例包.怎么了?

Symfony2 returns No route found for "GET /" when I try to run http://localhost/app_dev.php, but this url works: http://localhost/app_dev.php/hello/Symfony. I removed AcmeDemoBundle and I'm trying to run an example bundle from a symfony2 tutorial. What is wrong ?

app/config/routing.yml :

app/config/routing.yml :

ShopMyShopBundle:
resource: "@ShopMyShopBundle/Resources/config/routing.yml"
prefix:   /

app/config/routing_dev.yml :

app/config/routing_dev.yml :

_assetic:
resource: .
type:     assetic

_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix:   /_wdt

_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix:   /_profiler

_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix:   /_configurator

_main:
resource: routing.yml

src/Shop/MyShopBundle/Resources/config/routing.yml :

src/Shop/MyShopBundle/Resources/config/routing.yml :

ShopMyShopBundle_homepage:
pattern:  /hello/{name}
defaults: { _controller: ShopMyShopBundle:Main:index }
requirements:
    _method:  GET

推荐答案

问题是你没有 / 的路由.将您的定义更改为:

The problem is that you don't have a route for /. Change your definition to this:

ShopMyShopBundle_homepage:
    pattern:  /
    defaults: { _controller: ShopMyShopBundle:Main:index }
    requirements:
        _method:  GET

这篇关于symfony 2 找不到“GET/"的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆