Order of Route in Symfony
<p>I Use Symfony 3, And I Want to understand How symfony chouses the Route.</p>

<p>I have 3 routes, 2 in routing.yml and 1 in annotation.
this is my code:</p>

<p>app/config/routing.yml</p>

<pre><code>app:
    resource: "@AppBundle/Controller/"
    type:     annotation

hello:
    path: "hello/{firstName}"
    defaults: {_controller: AppBundle:Default:rotta,firstName: "route1"}

hello_name:
    path: "hello/{firstName}"
    defaults:  {_controller: AppBundle:Default:rotta, firstName: "route2"}
</code></pre>

<p>src/AppBundle/Controller/DefaultController.php</p>

<pre><code>/**
 * @Route("hello/{firstName}", name="hello", defaults={"firstName" = "Annotation"})
 */
public function rottaAction($firstName,Request $request)
{
    var_dump($request-&gt;get('firstName'));
    exit;
}
</code></pre>

<p>My result is </p>

<pre><code>string 'route1' (length=6)
</code></pre>

<p>with this routing.yml</p>

<pre><code>hello:
    path: "hello/{firstName}"
    defaults: {_controller: AppBundle:Default:rotta,firstName: "route1"}

hello_name:
    path: "hello/{firstName}"
    defaults:  {_controller: AppBundle:Default:rotta, firstName: "route2"}

app:
    resource: "@AppBundle/Controller/"
    type:     annotation
</code></pre>

<p>My result is</p>

<pre><code>string 'route2' (length=6)
</code></pre>

<p>and with this combination:</p>

<pre><code>hello:
    path: "hello/{firstName}"
    defaults: {_controller: AppBundle:Default:rotta,firstName: "route1"}

hello_name:
    path: "hello/{firstName}"
    defaults:  {_controller: AppBundle:Default:rotta, firstName: "route2"}

#app:
#    resource: "@AppBundle/Controller/"
#    type:     annotation
</code></pre>

<p>my result is:</p>

<pre><code>string 'route1' (length=6)
</code></pre>