首页 > thinkphp中控制器的划分有什么规范吗?

thinkphp中控制器的划分有什么规范吗?

我的理解是每一个功能模块划分出一个控制器,这样的话,方便以后需求出现变动的时候,修改起来能尽可能的不影响其他模块

但是也看到有人说把所有输出视图的方法都单独抽出来写到IndexController控制器里面,而IndexController控制器里面再去调用其他控制器的方法。想想好像他们说的也有道理。
但是感觉如果后期需求有变动,那么IndexController控制器也要进行修改,好像又违反了高内聚低耦合的原则。(应该是同一个功能下输出视图和数据处理应该是内聚在同一个控制器下)

搞的我现在不知道到底该怎么划分控制器了,有没有人能分享一下自己的划分方式以及规范。


目前我们使用thinkphp是两种方式放在一起使用的
.
|-- Login
| `-- Action
| |-- IndexAction.class.php
| `-- LoginAction.class.php
|-- Query
| `-- Action
| |-- AgentChargeLogAction.class.php
| |-- AgentFundsLogAction.class.php
| |-- IndexAction.class.php
| |-- MobileTelAction.class.php
| |-- OrderQueryAction.class.php
| |-- ProductAction.class.php
| `-- UserAction.class.php
|-- Trade
| `-- Action
| |-- CardlibAction.class.php
| |-- FlowAction.class.php
| |-- IndexAction.class.php
| |-- QcoinsAction.class.php
| `-- TelAction.class.php

我们每个功能模块划分出一个目录。
把所有输出视图的方法都单独抽出来写到IndexAction(3.1版本)控制器里面,而IndexAction控制器里面再去调用其他控制器的方法。


建议一个功能模块一个控制器或者一个文件夹。这样维护修改都方便

【热门文章】
【热门文章】