4

I usually did a FrontendBundle and BackendBundle but with Symfony 4 all is in src folder. Do I have to put all my controllers together (I do not think so) or create 2 folders (Controller and ControllerFront)?

For exemple: (file Symfony/config/routes/annotations.yaml)

controllers:
    resource: ../../src/Controller/
    type: annotation
    prefix: /admin


controllers_front:
    resource: ../../src/ControllerFront/
    type: annotation
    prefix: /

It's correct ? If not what is the best way ?

Sorry for my english. I try to improve it ;-)

Joris Saenger
  • 141
  • 1
  • 10
  • 1
    Honestly it's your preference and what you're comfortable with. since you're able to specify any storage location for the controller resource, it's very opinionated. For your specific use-case, I would prefer `src/Controller/Frontend` and `src/Controller/BackEnd` to segregate the functionality of the controllers. Then all you would need to do is specify `{resource: ../../src/Controller/, type: annotation, prefix: /}` to handle all general controllers, and below that declaration override the definition with `{resource: ../../src/Controller/Backend, type: annotation, prefix: /admin}` – Will B. Apr 26 '18 at 22:12

1 Answers1

3

Basically, SF4 let's you organize your files the way you want and feel more comfortable with, although there is some recommendations that can easily be found in SF's documentation.

That being said, if you want some insights, a discussion about that has already taken place here : Symfony 4: How to organize folder structure (namely, your business logic)

WhoSayIn
  • 4,449
  • 3
  • 20
  • 19
Aurelien
  • 1,497
  • 7
  • 15