🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 控制器定义 控制器文件通常放在`插件路径/inc/module`下面,类名和文件名保持大小写一致,并采用驼峰命名(首字母大写)。 一个典型的控制器类定义如下: ~~~ // +---------------------------------------------------------------------- // | onegow [ WE CAN DO IT MORE SIMPLE] // +---------------------------------------------------------------------- // | Copyright (c) 2016-2018 http://onegow.com All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: mrye 55585190@qq.com // +---------------------------------------------------------------------- namespace inc\mobile; class Index extends Base { /** * 前台首页 */ public function index() { $this->view(); } } ~~~ > 为了插件编码的统一规范,控制器类继承插件的基类控制器`Og_testModuleSite`,不同插件继承的类名称可能会不一样。 控制器类文件的实际位置是 ~~~ 插件路径\inc\mobile\Index.php ~~~ 访问URL地址是(假设没有定义路由的情况下) ~~~ http://localhost/app/index.php?i=2&c=entry&do=index&m=og_test ~~~ 如果你的控制器是`HelloWorld`,并且定义如下: ~~~ <?php // +---------------------------------------------------------------------- // | onegow [ WE CAN DO IT MORE SIMPLE] // +---------------------------------------------------------------------- // | Copyright (c) 2016-2018 http://onegow.com All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: mrye 55585190@qq.com // +---------------------------------------------------------------------- namespace inc\mobile; class Index extends Base { /** * 前台首页 */ public function index() { return 'HelloWorld'; } } ~~~