I have more than 50 menus which I need to create custom. as per the module structure, we need to create routing.yml in root folder. but I want to do something like this below:

      -  products(folder)
              - routing.yml
              - src(folder)
                - productController  
      -  brands(folder)
              - routing.yml
              - src(folder)
                - brandsController.php    
      - myModule.info.yml
      - myModule.module

is it way to do achive something like this.

I just want to make code seperation and avoid to add all routes in routing.yml

3 Answers 3


Instead of adding multiple routing files, you can define products, brands as modules inside your main module and then can define routing file for each of them like what is done in aggregator module in core. aggregator-module-core


The routing.yml can split by multiple files. You can include separate routing files in your routing.yml file.

  resource: "@acmeDemoBundle/Resources/config/routing/user_routing.yml"
  prefix: /user
  resource: "@acmeDemoBundle/Resources/config/routing/vehicles_routing.yml"
  prefix: /vehicles

It would works in symfony not sure in drupal 8, I hope it would works in drupal 8 too. Source : https://stackoverflow.com/questions/16355385/symfony2-splitting-routing-yml-in-multiple-files


the included routing files in a single file reouting.yml does not work under drupal because in drupal there is not the notion of bundle

I tested by passing the module name and also the namespace but it does not work

  resource: "@module_name/routing/salesforce_front_routing.yml"

  resource: "@Drupal/module_name/routing/salesforce_front_routing.yml"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.