myTD
myTD

Reputation: 1469

Linking in Symfony

I am trying to create a link for FOSUser Bundle.. It seems pretty straight forward, but for some reason i am having a problem..

i want to create a "Login" link inside my twig.

<a class="Link" href="{{ url('/login') }}">Login</a>

which should direct to http://localhost:9911/Symfony/web/app_dev.php/login as defined in my controller.

Am I doing this incorrectly?

Upvotes: 0

Views: 121

Answers (1)

dbrumann
dbrumann

Reputation: 17166

If you want to link to routes you can just use {{ path() }} or {{ url() }} and use the name of the route as argument. I was just about to tell you that you should read the documentation, but it actually doesn't mention the login-route. Who would have guessed?

You can find out the name of a route by looking into Resources/config/routing/*.yml. In your case the route is named fos_user_security_login, therefore linking to this route is as easy as using:

<a href="{{ path('fos_user_security_login') }}">login</a>

Upvotes: 6

Related Questions