-1

I am pretty much new into this world of the PHP MVC, so I apologize for any obvious answer.

When it comes to the Controller, should I create multiple individual files like "login.php" and "logout.php" and then have the login form action point to "controller/login.php"?

form action="controller/login.php" method="post"

or

form action="controller/controller.php" method="post"

In case the second is the correct one, should I include or extend the "login.php" (assuming it should still exist in a different file) into the controller.php?

I am just wondering if from a design perspective this is correct. I have read: Should I extend Controller or Create Helper? Single Controller with Multiple Views ,which seem to be similar (with a different language though), but I am still not sure that I got it.

Thanks in advance,

4

1 回答 1

0

控制器通常不仅仅是一个动作。控制器代表特定模块的一组操作。例如,用户控制器将具有典型的 CRUD 操作,然后可能是登录/注销操作,可能还有注册(可能在创建下)或忘记密码操作。如果您正在创建博客,则帖子/条目控制器很可能仅具有典型的 CRUD 操作,也可能具有评论操作。所以基本上每个模块或每个模型都有一个控制器。

您的所有控制器都应该扩展类似的基础,但对于整个项目而言,它不必相同。

您的表单将如下所示:action="controllerName/actionName"action="controller.php?q=controllerName/actionName取决于您如何进行 mod-rewrite 设置。

就视图而言,每个控制器操作都可能有多个视图(取决于 POST 或 GET 数据),但每个操作都有一个视图是相当标准的。

于 2013-09-04T15:41:51.873 回答