我需要将后端和前端的模型、视图和控制器分开吗?

发布于 2024-10-01 00:35:41 字数 434 浏览 1 评论 0原文

我正在从头开始为房地产网站开发 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 技术交流群。

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

发布评论

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

评论(3

乖不如嘢 2024-10-08 00:35:41

我最近做了类似的事情,包括公共区域和行政区域。我研究了具有访问控制功能的常见控制器,但很快意识到它们最好分开保存。

您的应用程序逻辑在管理部分会有所不同,您的模板也会有所不同。唯一相似的是您的模型,因此可以共享这些模型以避免数据重复。您可以做的是扩展管理部分的模型,以防您想向它们添加特定于管理的功能。

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.

苄①跕圉湢 2024-10-08 00:35:41

可能是前者。然而 - 我认为没有必要分成三部分。只有两个 - 普通和管理。因为管理员只会使用常用功能并添加一些用于写入的功能,而通用只是用于读取的功能。

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.

蓝海 2024-10-08 00:35:41

实际上,在获得适当许可的情况下,我会继续进行后者。

I would actually go on the latter with proper permissions.

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