M
M
magary42016-04-21 16:37:12
symfony
magary4, 2016-04-21 16:37:12

Separation within a bundle?

if the bundle is large, is it possible to separate the logic inside its type

MyBundle
     Download
          Controller
                several controllers here
          Resources
    
    Search
          Controller
               several controllers here
          Resources

and is it worth it?
can there be an example of how to do this division correctly?
when the bundle is big but not big enough to make 2 bundles

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-04-21
@magary4

when the bundle is big but not big enough to make 2 bundles

We read symfony best practice - you should always have only one bundle. AppBundle. All other bundle options are only for self-sufficient things that you want to reuse between projects. Moreover, as a rule, "in a bundle" it is not worth wrapping it up in advance, and already when it will be clear that something reusable has turned out.
Further, separation by functionality is a good thing. Just do not forget that controllers have a very mediocre relationship to the application, it's just UI. It makes sense to divide by layers / areas of responsibility + by functionality. so we can have a structure like this:
Controller
    User
       UserController
Entity
   - User
       - UserProfile
       - UserCredentials
       - User
       - UserRepository (только интерфейс)
   - Downloads
       - какие-то сущности

In a word, do as you please. But it's better to have 10 files in one directory than if we had 5 directories and 1-2 files in each.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question