您如何在Symfony2项目中组织捆绑软件? [英] How do you organize your bundles in Symfony2 projects?
问题描述
我有一个关于这个人的确切问题: http:// groups。 google.com/group/symfony2/browse_thread/thread/cd35132cc6972f29
I have the exact question that this guy has: http://groups.google.com/group/symfony2/browse_thread/thread/cd35132cc6972f29
我将在此处复制粘贴:
我想知道人们正在使用的
项目中组织捆绑的不同方式。
I was wondering what different ways of organizing bundles within a project people are using.
I似乎最终要么是一个项目的大量捆绑包,要么是彼此密切相关(依赖)的大量捆绑包。例如;
I seem to end up with either one massive bundle for a project or a lot of bundles which are closely related (dependant) to each other. eg;
我实现了自己的用户实体和登录表单等,但是用户
链接到组织(具有某些功能)。等等...主要是
个实体,我猜它们重叠很多...
I implemented my own user entity and login forms etc, but the users are linked to an organization (with some functionality). Etc ... It's mostly the entities that overlap a lot I guess ...
你们是把它们分开还是全部丢在同一捆中?
Do you guys split them up or dump them all in the same bundle?
推荐答案
Edit: I don't use bundles for app-specific code anymore.
我个人更喜欢在应用程序的每个部分都具有捆绑软件。例如:
Personally I prefer to have a bundle per a section of an application. For example:
- UserBundle
- BlogBundle
- ForumBundle
- JobBundle
- StoreBundle
- etc
- UserBundle
- BlogBundle
- ForumBundle
- JobBundle
- StoreBundle
- etc
如果该应用程序包含多个功能,那么这些功能就可以了,这些功能都不大到需要单独的应用程序和/或子域。但是,如果我正在开发大型的网络商店应用程序,则我的捆绑软件将更加具体:
This is okay if the app is a mishmash of several functionalities, none of which is big enough to require a separate application and/or a subdomain. But if I was developing a big webstore applicaton, my bundles would be more specific:
- UserBundle
- ProductBundle
- 购物车
- SearchBundle
- WishlistBundle
- 等
- UserBundle
- ProductBundle
- CartBundle
- SearchBundle
- WishlistBundle
- etc
所以,我想说,这取决于项目的重点。一个项目的一部分可能是另一个项目的核心功能。
So, I'd say, it depends on the focus of the project. What's just a section for one project could be the core functionality of another.
我通常有 CommonBundle ,所有常见内容都放在其中,例如全局CSS,图像,布局等。
And I usually have CommonBundle, where all the common stuff goes, like global CSS, images, layouts, etc.
后端组织也至少有两个选择:
Also there are at least two options for the backend organization:
- 每个捆绑包都有自己的后端部分,或者
- 有一个大的后端捆绑包。
我个人倾向于第一种选择,您可以在我的上一个答案中了解它。 ,但有些人更愿意为整个后端使用单独的捆绑软件-可能使用管理捆绑软件之一。
Personally I lean towards the first option and you can read about it in my previous answer, but there are people who prefer to have a separate bundle for the whole backend — probably using one of the admin bundles.
顺便说一下,将束相互连接是完全可以的-您不必使它们彼此独立。例如, JMSDiExtraBundle 取决于元数据库和 JMSAopBundle 在 cg-library 中。如果您尝试使捆绑包完全独立,则最终会遇到一大堆的一大堆代码。
By the way, it's perfectly okay for bundles to be interconnected — you don't have to make them all independent of each other. For example, JMSDiExtraBundle depends on the metadata library and JMSAopBundle, which in turn depends on cg-library. If you'll try to keep bundles totally independent, you'll end up with big monolithic one-bundle lumps of code.
这篇关于您如何在Symfony2项目中组织捆绑软件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!