我需要将后端和前端的模型、视图和控制器分开吗?
我正在从头开始为房地产网站开发 MVC 引擎。
目前我有这样的文件夹结构:
/app
/frontend
/controller
/model
/view
/backend
/controller
/model
/view
/common
/controller
/model
/view
/lib
/log
index.php
backend.php
config.php
bootstrap.php
.htaccess
以这种方式将公共网站和管理网站的 MVC 类分开是个好主意吗? 或者最好为所有 MVC 类创建一个文件夹并为创建、更新、删除等操作设置权限?哪个更安全?
谢谢。
I'm developing MVC engine for real estate web-site from scratch.
Currently I have this folder structure:
/app
/frontend
/controller
/model
/view
/backend
/controller
/model
/view
/common
/controller
/model
/view
/lib
/log
index.php
backend.php
config.php
bootstrap.php
.htaccess
It is good idea to separate MVC classes for public and admin website such way?
Or it is better to make one folder for all MVC classes and set privilegies for actions like create, update, delete? Which is more secure?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最近做了类似的事情,包括公共区域和行政区域。我研究了具有访问控制功能的常见控制器,但很快意识到它们最好分开保存。
您的应用程序逻辑在管理部分会有所不同,您的模板也会有所不同。唯一相似的是您的模型,因此可以共享这些模型以避免数据重复。您可以做的是扩展管理部分的模型,以防您想向它们添加特定于管理的功能。
I did something similar recently that included a public and an administrative area. I investigated common controllers with access controls but soon realized they were better off kept separately.
Your application logic will differ in the administrative section, and so will your templates. The only thing similar will be your models so those can be shared to avoid duplication of data. What you can do is extend your models for your administrative section in case you want to add admin-specific functionality to them.
可能是前者。然而 - 我认为没有必要分成三部分。只有两个 - 普通和管理。因为管理员只会使用常用功能并添加一些用于写入的功能,而通用只是用于读取的功能。
Probably the former. However - I think it is not needed to split into 3 parts. Just two - common and admin. Because the admin will just use common functions and adds some for writing, while common are just functions for reading.
实际上,在获得适当许可的情况下,我会继续进行后者。
I would actually go on the latter with proper permissions.