关于MVC文件夹结构的问题 [英] Question about MVC folder structure

查看:44
本文介绍了关于MVC文件夹结构的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使用 MVC 模式/布局结构,它是否基本上需要通过 1 个文件加载所有内容,例如您的索引文件?

To use the MVC pattern/layout structure, does it basicly require everything to be loaded through 1 file, like your index file?

推荐答案

没有.MVC 模式仅规定了有关事件/请求处理、数据建模和用户界面的关注点分离.未指定实现方式.

No. The MVC pattern only dictates a separation of concerns regarding event/request handling, data modelling and user interface. The way this is implemented is not specified.

我所知道的许多(全部?)当前 PHP 框架确实使用单个入口点 (index.php) 并从那里路由.这通常使用前端控制器"模式.

Many (all?) of the current PHP frameworks I am aware of do use a single entry point (index.php) and route from there. This often makes use of the "Front Controller" pattern.

另一种方法(每页使用单独的 PHP 文件)称为页面控制器模式.它的优点是更简单,但失去了前端控制器提供的应用程序范围的控制,并且可能容易出现代码重复.

The other method (using a separate PHP file per page) is known as the Page Controller pattern. It has the advantage of being much simpler, but loses the application wide control afforded by the front controller and may be prone to code duplication.

这篇关于关于MVC文件夹结构的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆