0

I've got a pure Symfony app. I had made own bundle, and want to define routes inside it via annotations/attributes.

I don't want to define routes inside main app space - bundle should be installed and routes immediately included for sake of easier installation and maintenance.

I already tried to load them this way:

controllers:
  resource: "../src/Controller/"
  type: attribute

and pretty much other ways, none work.

What's the proper way?

4
  • It's not very common to register routes automatically from a bundle. Usually your documentation tell the user how to install and configure your bundle. Not sure you should persist in this way :)
    – Mcsky
    Commented Dec 2 at 8:24
  • 1
    Basically you can't and this is by design. The Symfony designers did not want bundles to be able to add routes without at least one line of configuration at the app level.
    – Cerad
    Commented Dec 2 at 13:25
  • @Cerad, is this your answer? The icon is the same, so I'm guessing yes? I'm not going to get into the good/bad argument, but that answer shows the "one line of configuration" that should make this work, hopefully, for the OP. Also, would a recipe be the trick for the automatic configuration of this then?
    – Chris Haas
    Commented Dec 2 at 21:58
  • @ChrisHaas It is my answer. I suppose you could use a recipe to add the entry to the routes file but that would still be "inside the app space".
    – Cerad
    Commented Dec 3 at 13:41

0

Your Answer

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