0
votes

Is it possible in Symfony 4 to set the routing name trough yaml.

So old annotation

/**
 * @Route("/cms", name="security_login")
 */
public function loginAction(Request $request, AuthenticationUtils $authenticationUtils) {
   // code here
}

Yaml annotation

login:
    path:       /cms
    controller: App\Controller\SecurityController::loginAction
    name: security_login

It looks like yaml doesn't support the name key. only the following keys are supported:

"resource", "type", "prefix", "path", "host", "schemes", "methods", "defaults", "requirements", "options", "condition", "controller".

or is the key 'login' the name?

2

2 Answers

1
votes

Yes, the "login" key in your file is the route's name.
Click on the "YAML" tabs in the documentation to see yaml examples :

# config/routes.yaml
blog_list:
    path:     /blog
    controller: App\Controller\BlogController::list

blog_show:
    path:     /blog/{slug}
    controller: App\Controller\BlogController::show

Corresponds to these annotations :

/**
 * Matches /blog exactly
 * @Route("/blog", name="blog_list")
 */
public function list()
{
    // ...
}

/**
 * Matches /blog/*
 * @Route("/blog/{slug}", name="blog_show")
 */
public function show($slug)
{
    // ...
}
0
votes

The name is specified in the yaml entry ...

security_login:
    path:       /cms
    controller: App\Controller\SecurityController::loginAction