symfony怎么分Bundle好?

Symfony什么样的情况下分Bundle?假设要建设一个博客类型的网站,我应该直接全部写在一个BlogBundle 还是后台处理放在AdminBundle,Api处理放在ApiBundle。用户处理放在UserBundle等等之类的?求助,之前都是扔一块,今天认真的思考了下,突然有点凌乱。

阅读 4.6k
2 个回答

在一个bundle里面按不同的文件夹分就可以了。这个地方关键还是看你的路由设计,在controller里

按照我们公司的做法,按功能分不同的bundle,在bundle内按照楼上的再分不同的文件夹

看一下手册的定义行不

A bundle is simply a structured set of files within a directory that
implement a single feature. You might create a BlogBundle, a
ForumBundle or a bundle for user management (many of these exist
already as open source bundles). Each directory contains everything
related to that feature, including PHP files, templates, stylesheets,
JavaScript files, tests and anything else. Every aspect of a feature
exists in a bundle and every feature lives in a bundle.

bundle是一个在目录中实现单个功能的结构化文件集。您可以为用户管理创建一个BlogBundle、ForumBundle或bundle(其中许多已经存在为开放源代码包)。每个目录都包含与该功能相关的所有内容,包括php文件、模板、样式表、javascript文件、测试和其他任何内容

你的整个网站就只有一个功能么?Bundle的设计不是为了增加程序耦合度,而是为了降低功能之间的耦合度。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进