title: Symfony2 multiple config and routing files for subdomain routing
body: <p>We are building a Symfony2 application that will serve different sections using subdomains:</p>
  
  <ol>
  <li>api.tld.com - API system</li>
  <li>docs.tld.com - Documentation</li>
  <li>assets.tld.com - System for serving images</li>
  </ol>
  
  <p>How we are doing this is creating an app directory for each subdomain, and keeping the standard /app directory in place as the central shared config. There is also a custom bootstrap in the web directory for each app. Subdomains are routed accordingly using .htaccess.</p>
  
  <p>The problem I am having is where multiple config files come in, particularly when they have their own routing imports. In some cases, there can be up to 4 configs.yml files. Take the following URL for example:</p>
  
  <p><a href="http://testing.docs.tld.com" rel="nofollow">http://testing.docs.tld.com</a></p>
  
  <p>The config setup currently works like this (and it works)</p>
  
  <ol>
  <li>tld.com - Global config located at /app/config/config.yml</li>
  <li>testing - Environment config located at /app/config/config_testing.yml. This config also imports config_dev.yml in the same directory.</li>
  <li>docs - App config located at /app_docs/config/config.yml</li>
  </ol>
  
  <p>These are all imported in the AppKernal in /app_docs/AppKernal.php:</p>
  
  <pre><code>// Load Global Configuration
  // ROUTES INSIDE THIS CONFIG ARE NOT BEING LOADED
  $loader-&gt;load(__DIR__.'/../app/config/config.yml');
  
  // Load Environment Configuration
  // ROUTES INSIDE THIS CONFIG ARE NOT BEING LOADED
  $loader-&gt;load(__DIR__.'/../app/config/config_' . $this-&gt;getEnvironment() . '.yml');
  
  // Load App-centric Configuration
  $loader-&gt;load(__DIR__.'/config/config.yml');
  </code></pre>
  
  <p>Now the configs load just fine. But what I'm having trouble with, and not found any definitive documentation on, is when more than one of these configs define framework: router: resources. In the above example configs, these are loaded (attempted to anyway) as follows:</p>
  
  <p><strong>/app/config/config.yml</strong></p>
  
  <pre><code>framework:
      secret:%secret%
      router:
          resource: "%kernel.root_dir%/config/routing.yml"
          strict_requirements: %kernel.debug%
  </code></pre>
  
  <p><strong>/app/config/config_testing.yml</strong></p>
  
  <pre><code>// No special Routing
  </code></pre>
  
  <p><strong>/app/config/config_dev.yml</strong></p>
  
  <pre><code>framework:
      router:   { resource: "%kernel.root_dir%/config/routing_dev.yml" }
  </code></pre>
  
  <p><strong>/app_docs/config/config.yml</strong></p>
  
  <pre><code>framework:
      secret: %secret%
      router:
          resource: "%kernel.root_dir%/config/routing.yml"
          strict_requirements: %kernel.debug%
  </code></pre>
  
  <p>All of the configs are loading fine. But what I found is that only the last routing file called above is being included. So I assume the rule is that they are overriden as a rule, rather than extended.</p>
  
  <p>So what I have spent the last couple of days trying to find out is, is it possible to extend the inclusion of routing files within config files in the fashion above? Another option I investigated was to find a way to import routing files in the AppKernal files. I was only able to find <a href="http://symfony.com/doc/2.0/components/routing.html#load-routes-from-a-file" rel="nofollow">this</a>, which doesn't explain exactly at what point this should be used (or where). It doesn't work within the AppKernal where the configs are included, so I assume the Router is not active at that stage.</p>
  
  <p>Anyone have any ideas? I'd be very grateful.</p>