Symfony2 捆绑系统
我正在研究 Symfony2 Bible,但我对捆绑系统有点困惑。这是一个很棒的功能,但我不太确定如何将我的平面 PHP 应用程序分割成多个包。这是我第一次将 PHP 代码拆分为功能齐全的 MVC 框架。
我正在开发一些在线游戏(基于 PHP),但我如何定义捆绑包?它是否像一个包含所有控制器和功能的 onlinegame1 捆绑包 - 或者像登录捆绑包、注册捆绑包、战争捆绑包 - 为我获得的每个 PHP 文件总结了一个捆绑包?
我想开始干净和正确,但我不太确定我是否理解该功能。
I'm just working through the Symfony2 Bible and I'm a little stuck on the bundle system. It is a great feature but I'm not quite sure how to split my flat PHP application into bundles. It's my first time splitting my PHP code into a full featured MVC framework.
I'm working on a few online games (based on PHP) but how would I define the bundles ? Is it like one single onlinegame1 bundle with all the controllers and functions - Or like a login bundle, a register bundle, a war bundle - summarized one bundle for every single PHP file I got ?
I want to start clean and correct but I'm not quite sure if I understand that feature.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将捆绑视为一个独立的可重用组件 - 至少在大多数情况下如此。
让我们想象一个个人博客网站。我将其分成
ArticleBundle
、UserBundle
、CommentBundle
以及最后的MainBundle
,它将所有其他捆绑包粘在一起,创建您的网站。要点是,您可以以 ArticleBundle 为例,并在其他项目中轻松地重用它,而无需将其绑定到任何其他包。来自Symfony2 书:
You could think of bundle as an independent reusable component - in most of the cases at least.
Let's imagine a personal blog website. I'd split it into
ArticleBundle
,UserBundle
,CommentBundle
and finallyMainBundle
which would stick all these other bundles together, creating your website. The main point is that you can take for example ArticleBundle and reuse it easily on other project without it being tied to any other bundle.From Symfony2 book: