dpy3846 2015-01-22 11:16
浏览 22
已采纳

Symfony2捆绑包应该包含什么?

I know a Symfony2 bundle should contain a common set of features. However, how granular do you define that set of features? For example, I have a ContentBundle which deals with creating and editing content. Then I have a TaxonomyBundle which handles tagging and categories etc. Finally I have a PollsBundle, which deals with polls.

The trouble I'm having is that the doctrine entities rely on entities in other bundles. For example I have an entity 'Type' in TaxonomyBundle, and a 'Poll' in PollBundle belongs to 'Type'. Finally 'Type' belongs to 'Content' in the ContentBundle.

Am I being too granular when trying to separate concerns? Should things like content and taxonomy be a part of the same bundle?

tl;dr how wide a scope, in terms of features should a Symfony2 bundle be?

  • 写回答

1条回答 默认 最新

  • dsfsdfsdfsdfsdf45454 2015-01-22 11:21
    关注

    According to Symfony best practices :

    But a bundle is meant to be something that can be reused as a stand-alone piece of software. If UserBundle cannot be used "as is" in other Symfony apps, then it shouldn't be its own bundle. Moreover InvoiceBundle depends on ProductBundle, then there's no advantage to having two separate bundles.

    So it looks that in your case this rule applies:

    Best Practice

    Create only one bundle called AppBundle for your application logic

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?