FOSUserBundle : no route found for Security:Login

喜欢而已 提交于 2019-12-23 19:42:35

问题


I post a problem here few days ago : FOSUserBundle: embedding the login form and choosing its template

But it's pretty complicated, and I think behind this problem, there is maybe a simple problem of route, so I think it's a good idea to create a parallel topic, delete all the modifications I do, and start with fresh new installation.

So, I install FOSUserBundle, I have a WelcomeBundle, which contains the several pages of my website, and I also create a fresh UserBundle, which only contains the User Entity for FOSUserBundle, nothing else (no override of anything).

In my rsWelcomeBundle, in my index.html.twig, I put this simple code :

{% extends "rsWelcomeBundle::layout.html.twig" %}

{% block title "Page d'accueil" %}

{%  block body %}
    <div class="span6">
        <div class="well">
            <h2>Présentation du jeu</h2>
            <a href="{{ path('rsWelcomeBundle_homepage_inscription') }}" class="btn ">Je m'inscris !</a></p>
        </div>
    </div>
    <div class="span6">
        <div class="well">
            {% render "FOSUserBundle:Security:login" %}
        </div>
    </div>

{% endblock %}

And I always have this error :

An exception has been thrown during the rendering of a template ("No route found for "GET Security:login"") in rsWelcomeBundle:Homepage:index.html.twig at line 1.

If I put this line for the render part it's working.

{% render(controller("FOSUserBundle:Security:login")) %}

But why ?? In the documentation I never see we've to use "render(controller". Why I can't use directly : render "FOSUserBundle:Security:login" ?

In app/config/routing.yml I have :

tuto_welcome:
    resource: "@rsWelcomeBundle/Resources/config/routing.yml"
    prefix:   /

fos_user_security:
    resource: "@FOSUserBundle/Resources/config/routing/security.xml"

fos_user_profile:
    resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
    prefix: /profile

fos_user_register:
    resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
    prefix: /register

fos_user_resetting:
    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
    prefix: /resetting

fos_user_change_password:
    resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
    prefix: /profile

In the UserBundle I don't have routing.yml. In the WelcomeBundle I have this in routing.yml :

rsWelcomeBundle_homepage:
    pattern:  /
    defaults: { _controller: "rsWelcomeBundle:Homepage:index" }

It's been two days I try to fix this problem, could you help me ?

Thanks a lot to everyone !


回答1:


{% render "FOSUserBundle:Security:login" %} is the Symfony 2.0 way to render a subrequest. {{ render(controller("FOSUserBundle:Security:login")) }} is the syntax for 2.1+. Both syntax basically mean the same exact thing.

Documentation about subrequests is here: http://symfony.com/doc/current/quick_tour/the_view.html#embedding-other-controllers




回答2:


Try using {% render url('your url') %} instead.



来源:https://stackoverflow.com/questions/15855515/fosuserbundle-no-route-found-for-securitylogin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!