Symfony2 headache design brings organization together

I develop SaaS where tenants are real and administrators (us). Thus, the fornt-end and back-end are the same. In any case, according to many other issues, bundles are a way to structure your project in a reusable way.

I really don't think that our packages will be reused, but I still need a way to split the project into packages in order to quickly find the files we want to work on. The application should:

  • CRUD for clients - tenants should be able to manage their clients / partnerships
  • CRUD for customer tags and keywords (a way to categorize your customers).
  • CRUD for our broadcast notifications (messaging system)
  • CRUD for tenants - we can manage our tenants

So how to organize my packages? May be:

  • CoreBundle : Doctrine2 models only
  • ResourcesBundle : templates, js, css, images
  • SystemUserBundle : manage tenants and CRUD clients
  • MessagingBundle : Messaging System

How can this design be improved?

+4
source share
1 answer

According to the Symfony2 documentation:

In Symfony2, a package is similar to a plugin, except that all the code in your application will live inside the package. A package is nothing more than a directory in which everything related to a particular function is stored, including PHP classes, configuration, and even style sheets and Javascript files (see. The Bundle System).

Personally, following this description, I would install SystemUserBundle to contain the Doctrine2 model and / js / css / images templates that are specifically related to client management, rather than splitting them into CoreBundle and ResourceBundle. However, dividing your application into SystemUserBundle and MessagingBundle sounds like a smart approach.

I like to think about it this way - does this package encapsulate any behavior that I might need, or want to connect to the future Symfony project (s) in which I participate. For example, customer management is something that can be applied to any application and be reused for projects (indeed, therefore there is an extensible FOSUserBundle).

I don’t think that Symfony2 documents describe packages in sufficient detail (yet!), But if you haven’t found all the relevant sections, these are the ones I know about:

+10
source

Source: https://habr.com/ru/post/1398567/


All Articles