title: How can I automatically register 'controllers as services' in other directories in Symfony 5
body: <h2>Background</h2>
  
  <p>I want to use <a href="https://en.wikipedia.org/wiki/Cohesion_(computer_science)" rel="nofollow noreferrer">functional cohesion</a> to organise my controllers. </p>
  
  <p>This means that I will not have a <code>Controllers/</code> directory, which makes it easy for the framework, but I will organise my code by use-case. An arbitrary example:</p>
  
  <ul>
  <li><code>src/FetchLatestNews/Controller.php</code></li>
  <li><code>src/FetchLatestNews/News.php</code></li>
  <li><code>src/FetchLatestNews/NewsRepository.php</code></li>
  <li>...etc</li>
  </ul>
  
  <p>However, Symfony is set up by default to require all controllers in one place. See <code>services.yaml</code>:</p>
  
  <pre class="lang-yaml prettyprint-override"><code>    # controllers are imported separately to make sure services can be injected
      # as action arguments even if you don't extend any base controller class
      App\Controller\:
          resource: '../src/Controller'
          tags: ['controller.service_arguments']
  </code></pre>
  
  <p>Following the above template, I <em>could</em> just place the new <code>src/FetchLatestNews/Controller</code> in there and then add each new controller each time. However, <strong>I don't want to, nor should I have to, manually update this file every time I create a new use-case</strong>.</p>
  
  <h2>Question</h2>
  
  <p>How can I avoid this error:</p>
  
  <blockquote>
    <p>maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"</p>
  </blockquote>
  
  <p>As a user I should not have to care about manually adding <code>service_arguments</code> or any other configuration. When I specify a route, the thing it's pointing to is therefore a controller.</p>
  
  <p>The ideal workflow would be:</p>
  
  <ul>
  <li>Create a controller wherever I like.</li>
  <li>Add a route to <code>routes.yaml</code> referencing the controller.</li>
  <li>That's it!</li>
  </ul>
  
  <p>Is it possible to achieve this workflow in Symfony? It should be, because anything from a route --> some class will be a controller. Is there a way to use a regex, or some other solution?</p>
  
  <p><em>Note</em>: <a href="https://stackoverflow.com/a/51910803/736809">this answer</a> suggests an empty interface sort of 'hack'. This is not ideal, either. Any alternatives?</p>