关于3层架构和symfony框架

发布于 2024-07-29 06:42:14 字数 104 浏览 2 评论 0原文

两者都是基于mvc。

但在3层架构中,存储层是一个单独的层,

而在symfony框架中,数据库(存储)层包含在模型层中。

为什么它们不同?

Both of them are based from mvc.

But in 3-tier architecture,storage layer is a separate layer,

while in symfony framework,database(storage) level is included in model layer.

Why are they different?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

递刀给你 2024-08-05 06:42:14

我想说 MVC 专注于用户交互。 它描述了如何开发一个丰富且灵活的系统来响应用户请求,但没有提及控制器层下面发生的事情。

它只是说:

  • 用户发送请求;
  • 调度员将请求转发给适当的控制器;
  • 控制器检索模型,但没有指定如何:使用模型的方法,使用 DAO 层,使用 Managers 层,等等;
  • 控制器转发到视图。

与许多其他层一样,CakePHP 也将模型和数据层粘合在一起。 这只是一个选择:这样您就可以减少层数和代码,但如果您改变主意,则必须直接在模型中修改所有代码。

I would say that MVC is focused on user-interaction. It describes how to develop a rich and flexible system that reacts to user requests, but says nothing about what happens below controller layer.

It just says:

  • user sends a request;
  • dispatcher forwards request to appropriate controller;
  • controller retrieves models, but it's not specified HOW: using model's methods, using a DAO layer, using a Managers layer, whatever;
  • controller forwards to a view.

CakePHP also has model and data layer glued together, as many others. It's just a choice: this way you have less layers and less code, but in case you change your mind you'll have to modify all your code, directly in the models.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文