简单的路由不适用于symfony

时间:2017-02-25 00:32:24

标签: php symfony

我将此添加到routing.yml

# app/config/routing.yml
sonata_media_pixlr:
    resource: '@SonataMediaBundle/Resources/config/routing/pixlr.xml'
    prefix: /admin/media

,这是对sonata_media.yml

# app/config/sonata_media.yml
sonata_media:
    # ...
    pixlr:
        enabled:  true
        secret:   theSecretHash
        referrer: Application Name

然后访问 /web/app_dev.php/admin/media

No route found for "GET /admin/media"

我认为这只是最简单的路由方式。

然而它并不起作用。我清除了缓存。

我需要检查一下吗?

或者是否有任何命令来检查路由的映射方式?

这些是我在下面的routing.yml

admin_area:
    resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
    prefix: /admin

_sonata_admin:
    resource: .
    type: sonata_admin
    prefix: /admin

acme_member:
    resource: "@AcmeMemberBundle/Resources/config/routing.yml"
    prefix:   /member

_user_bundle:
    resource: "@UserBundle/Resources/config/routing.yml"

acme_top:
    resource: "@AcmeTopBundle/Resources/config/routing.yml"
    prefix:   /

fos_user_group:
    resource: "@FOSUserBundle/Resources/config/routing/group.xml"
    prefix: /group


sonata_page_cache:
    resource: '@SonataCacheBundle/Resources/config/routing/cache.xml'
    prefix: /

gallery:
    resource: '@SonataMediaBundle/Resources/config/routing/gallery.xml'
    prefix: /media/gallery

media:
    resource: '@SonataMediaBundle/Resources/config/routing/media.xml'
    prefix: /media

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml"


fos_js_routing:
  resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"
 #FosUserBundle Routes
sonata_media_pixlr:
    resource: '@SonataMediaBundle/Resources/config/routing/pixlr.xml'
    prefix: /admin/media

2 个答案:

答案 0 :(得分:2)

您可以使用以下命令检查所有路线:

php app/console router:debug

我不知道如何处理奏鸣曲包但可能在内部它已经使用这条路线或路线,如admin/{var}。并且您没有显示pixlr.xml,您是否配置了任何路线?

答案 1 :(得分:0)

通过与SonataMediaBundle集成,您必须在routing.yml文件中设置:

sonata_media_pixlr:
    resource: '@SonataMediaBundle/Resources/config/routing/pixlr.xml'
    prefix: /sonata/media