mantuko
mantuko

Reputation: 143

FOSUserBundle with Symfony 3.0

I'm trying to get FOSUserBundle up and running after upgrading Symfony from version 2.6 to 3.0. On 2.6 I basically had a site, css and js we're handles by assetic, FOSUserBundle was up and running an I had configured SQLite via doctrine.

So before picking this project up again I did the upgrade because 2.6 was no longer supported.

Because I'm new to Symfony everything I did is more or less copied from the documentation. FOSUserBundle is showing up as an enabled bundle in dev-mode. Alle my code is in /src/AppBundle. I'm using the 2.0-dev version of FOSUserBundle (e770bfa to be precise).

Here's a part of my template:

<li>
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
    <a href="{{ path('fos_user_security_logout') }}">
        {{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
    </a>
{% else %}
    <a href="{{ path('fos_user_security_login') }}">
        {{ 'layout.login'|trans({}, 'FOSUserBundle') }}
    </a>
{% endif %}
</li>

At 2.6 I got

fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.yml"

in my /src/AppBundle/config/routing.xml. If I keep it this way I can't even load the site because of an Exception

"Unable to generate a URL for the named route "fos_user_security_login" as such route does not exist."

After putting it in /app/config/routing.yml my site shows and the other routes defined in /src/AppBundle/config/routing.xml work. So it was nothing wrong with this file.

When the site shows up the translation of the links is broken.

{{ 'layout.login'|trans({}, 'FOSUserBundle') }}

Shows up as "layout.login" instead aus Login as before with 2.6. And if I click the link to log in (the path is as expected /login). Symfony tells me:

Unable to find template "AppBundle:Pages:login.html.twig".

I don't get why it's looking for it in the AppBundle folder? According to what I read it should look for it in the FOSUserBundle folder or in /app/Ressources/FOSUserBundle/... which is where I put it to override the default template. I confirmed that this is still the way to override templates even with version 3.0.

I also tried to put the template in the AppBulde/Pages/ folder. Then it finds the template but it's still not working.

I cleared the cache multiple times (this solved another problem with assetic).

It look for me as if I'm missing a significant part to get FOSUserBundle working. Any suggestions on what I might have overlooked?

Upvotes: 1

Views: 871

Answers (1)

manzerbredes
manzerbredes

Reputation: 310

FOSUserBundle seems to be use 'xml' files for routing, and you have include an 'yml' file in your routing.xml:

fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.yml"

Upvotes: 3

Related Questions