title: Why doesn't Symfony 5.1 recognize routes configured on a "routes.php" file?
body: <p>I'm having a hard time trying to configure my routes using a <code>config/routes.php</code> file in Symfony 5.1.</p>
  
  <p>As per the <a href="https://symfony.com/doc/current/routing.html#creating-routes-in-yaml-xml-or-php-files" rel="nofollow noreferrer">Symfony routing documentation</a>, I should be able to configure my routes in a PHP file:</p>
  
  <blockquote>
    <p>Instead of defining routes in the controller classes, you can define them in a separate YAML, XML or <strong>PHP</strong> file. The main advantage is that they don't require any extra dependency.</p>
  </blockquote>
  
  <p>But in practice, Symfony only recognizes the routes if I put my routes in a file <code>routes.yaml</code>.</p>
  
  <p>Routes configured inside a file <strong>routes.php</strong> result in the error "No route found for "GET /something" (404 Not Found)".   When running <code>debug:router</code>, these routes are not listed.</p>
  
  <p>The same route works great when configured in <code>routes.yaml</code>.</p>
  
  <p>In a different project using <code>Symfony 5.0.8</code>, route configuration via <code>routes.php</code> is working like a charm. </p>
  
  <p><strong>This is how I tested it:</strong></p>
  
  <ol>
  <li><p>Created a controller (omitted, since it's no relevant, any controller would do)</p></li>
  <li><p>Created a <code>routes.php</code> file:</p></li>
  </ol>
  
  <pre class="lang-php prettyprint-override"><code>//config/routes.php example
  
  use App\Controller;
  use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
  
  return function(RoutingConfigurator $routes)
  {
      $routes-&gt;add('schools_list', '/schools')
          -&gt;controller([Controller\SchoolController::class, 'list'])
          -&gt;methods(['GET']);
  };
  </code></pre>
  
  <ol start="3">
  <li>Running <code>debug:router</code> will result in:</li>
  </ol>
  
  <pre><code> ---------------- -------- -------- ------ -------------------------- 
    Name             Method   Scheme   Host   Path                      
   ---------------- -------- -------- ------ -------------------------- 
    _preview_error   ANY      ANY      ANY    /_error/{code}.{_format}  
   ---------------- -------- -------- ------ -------------------------- 
  </code></pre>
  
  <ol start="4">
  <li>Configured the same route inside <code>routes.yaml</code>:</li>
  </ol>
  
  <pre class="lang-yaml prettyprint-override"><code>#config/routes.yaml
  schools_list:
      path: /schools
      controller: App\Controller\SchoolController::list
      methods: GET
  </code></pre>
  
  <ol start="5">
  <li>Running <code>debug:router</code> will result in:</li>
  </ol>
  
  <pre><code> ---------------- -------- -------- ------ -------------------------- 
    Name             Method   Scheme   Host   Path                      
   ---------------- -------- -------- ------ -------------------------- 
    _preview_error   ANY      ANY      ANY    /_error/{code}.{_format}  
    schools_list     GET      ANY      ANY    /schools                  
   ---------------- -------- -------- ------ -------------------------- 
  </code></pre>