热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

【TP】ThinkPHP5公共模块的设置与使用

useapp\common\UserAScommonUser这种取别名的方式,也可以这么使用,比如index下的User类要继承common模块的下的User类:classUser

use app\common\User AS commonUser 这种取别名的方式, 也可以这么使用, 比如 index下的User类要继承common模块的下的User类:
class User extends \app\common\controller\User {
}
这里一定要在app前加"\", 告诉自动载入函数 app是根命名空间
同样的道理, 在使用common模块下的User类, 可以这样做: $commOnUser=new \app\common\controller\User;
方法都是可行的,看哪种用起来方便

TP5.0是可以访问common模块的, 只需要把convention.php文件中的 // 禁止访问模块
'deny_module_list' => ['common'], 把common去掉, 注意这行代码不可以注释, 注释了程序不可以执行. 最好是在公共配置文件修改deny_module_list配置项.

 

 


推荐阅读
author-avatar
fishdenise_496
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有