How to share a Symfony2 model with several projects

后端 未结 2 1653
一生所求
一生所求 2021-02-07 11:53

We are creating a SaaS that monitors certain assets. This means it takes in data, saves it, and displays it in a webinterface.

For this, we have a few components that we

2条回答
  •  感情败类
    2021-02-07 12:46

    I haven't used this technique myself in a real world symfony2 app - but it's a pointer as you asked for any feedback.

    The service container seems to be the Smyfony2 method to make services available globally. So in your case the model access objects will be defined as services as discussed in the provided link, and then can be used from any bundle.

    Now in which bundle do the service objects go? We can put them into a separate bundle as they are shared among other bundles. However, I assume the model would not be perfectly symmetrical for all the bundles, so we can put the shared model into a separate bundle, and put bundle specific entities into the bundle itself. Then injection techniques discussed in the link above can be used to provide a full model specific to each bundle.

    This seems to provide maximum de-coupling.

    I'm interested in any feedback on this too as it's a common design scenario.

    Regards.

提交回复
热议问题