douxu3315 2010-01-31 18:04
浏览 11
已采纳

这对于大型PHP站点来说是一个很好的布局吗?

The whole MVC design confuses me a little bit as I have never used it. Below is the general layout of my current project...

The account folder holds basicly all my core files for my user system

root/account/login.php
root/account/home.php
root/account/logout.php
root/account/settings.php

Then I have a seperate folder for each "module" (forums, blogs, etc)

root/forums/ root/blogs/
root/mail/

Then any functions and classes and config files are loaded from an includes directory like this

root/includes/classes/ root/includes/bootstrap.php //this file autoloads the class files needed and ensures a DB connection sitewide

Most of the "work" is done inside the class files. Obviously I left out hundreds of files and several other folders ( css/ js/ images/ )

So I am wondering, does this seem like a good design for a large scale site? This isn't considered MVC is it? And Please do not refer me to a Framework.

  • 写回答

1条回答 默认 最新

  • douchuituo3032 2010-01-31 18:15
    关注

    No, it doesn't seem like you are necessarily using MVC. Most of the time they are grouped by their real MVC names:

    If I had to guess how you are splitting your files, your structure could look like this

    views/
      account/
        login.php
        home.php
        settings.php
        logout.php
    controllers/  #maybe what you call modules
      account.php
      blog.php
      mail.php
    models/       #maybe what you call "classes" are models
      account.php
      blog_entry.php
      comment.php
    

    Just a quick reference:

    • M odel = Class that handles all interaction with the database for a specific object/function and normally has a 1 to 1 ratio with a database record (And of course has relationships to other models).
    • V iew = Handles displaying content to the user. No business code (or very little) should be contained in these files. Database access, for example, should not be performed in the view.
    • C ontroller = Script that receives the requests from the user, decides which models to get involved, performs the necessary action (passing off as much as makes sense to individual models), then prepares the data to show the user and sends that to the view for display.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口