Symfony2 包究竟应该包含什么?

What exactly should a Symfony2 bundle contain?

我知道 Symfony2 包应该包含一组通用功能。但是,您定义这组功能的粒度如何?例如,我有一个 ContentBundle 用于创建和编辑内容。然后我有一个处理标记和类别等的 TaxonomyBundle。最后我有一个处理民意调查的 PollsBundle。

我遇到的问题是学说实体依赖于其他包中的实体。例如,我在 TaxonomyBundle 中有一个实体 'Type',在 PollBundle 中有一个 'Poll' 属于 'Type'。最后 'Type' 属于 ContentBundle 中的 'Content'。

我在尝试分离问题时是否 细化了?内容和分类法之类的东西应该属于同一个包吗?

tl;dr 就 Symfony2 捆绑包的功能而言,范围应该有多大?

根据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.

所以看起来这条规则适用于你的情况:

Best Practice

Create only one bundle called AppBundle for your application logic