Unable to generate a URL for the named route "login"
<p>I'm getting error <code>Unable to generate a URL for the named route "login" as such route does not exist.</code> when I start the server and try to access <a href="http://127.0.0.1:8000" rel="nofollow">http://127.0.0.1:8000</a>.</p>

<p>Direct access to /login gives: <code>No route found for "GET /login"</code> </p>

<p>This is with symfony3 and WITHOUT FOSBUNDLE!
Based on <a href="http://symfony.com/doc/current/cookbook/security/form_login_setup.html#create-the-correct-routes" rel="nofollow">symfony3 cookbook traditional log form</a>.</p>

<p>security.yml:</p>

<pre><code>security:

# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
    in_memory:
        memory: ~

firewalls:
    # disables authentication for assets and the profiler, adapt it according to your needs
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false

    main:
        anonymous: ~
        form_login:
          login_path: login
          check_path: login
          csrf_token_generator: security.csrf.token_manager
          default_target_path: application
          always_use_default_target_path: true
        # activate different ways to authenticate

        # http_basic: ~
        # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate

        # form_login: ~
        # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
access_control:
  - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUYSLY }
  - { path: ^/, roles: ROLE_ADMIN }
</code></pre>

<p>securityController.php:</p>

<pre><code>// src/AppBundle/Controller/SecurityContoller.php
namespace AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class SecurityController extends Controller
{
/**
 * @Route("/login", name="login")
 */
 public function loginAction(Request $request)
 {
  $authenticationUtils = $this-&gt;get('security.authentication_utils');

// login error, if there is one
$error = $authenticationUtils-&gt;getLastAuthenticationError();

// last username entered
$lastUsername = $authenticationUtils-&gt;getLastUsername();

return $this-&gt;render(
  'security/login.html.twig',
  array(
    'last_username' =&gt; $lastUsername,
    'error'         =&gt; $error,
  )
);
 }
}
</code></pre>