2

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

   myModule
      -  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

Thanks in advance.

4

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

2

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

acme_demo_user:
  resource: "@acmeDemoBundle/Resources/config/routing/user_routing.yml"
  prefix: /user
acme_demo_vehicles:
  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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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