thinkphp5错误:类型错误: Argument 1 passed to think\Hook::import() must be of the type array
来源:互联网 发布:python经典程序实例 编辑:程序博客网 时间:2024/06/04 21:16
点击进入视频教程
使用thinkPHP5的时候出现如下错误
类型错误: Argument 1 passed to think\Hook::import() must be of the type array, integer given, called in /data/php/college/thinkphp/library/think/App.php on line 509
问题原因分析
在我使用thinkphp5的
php think build
自动创建完项目的结构后出现了如下错误。那么问题应该就出在自动构建的文件中。其实通过以上的错误可以看出。出问题的地方就是Hook中执行import进行钩子的挂载时出问题了。这个问题的原因分析之前我们先来看看自动构建文件build.php的结构。
'frontend' => [ '__file__' => ['common.php', 'config.php', 'tags.php'], '__dir__' => ['behavior', 'controller', 'model', 'view'] ]
这个写法自然是没有问题的。但是在自动生成的问题件中有个一tags.php打开tags.php可以发现是一个空的PHP文件。
问题解决
问题就出在这儿
tags.php会在程序初始化时载入,载入后会去分析tags.php中的配置而且是不加判断直接传入到Hook的import中的。这样就会导致这样的一个错误。所以如果tags.php是留着项目后期使用的那么就需要这样来写返回一个空数组:
<?phpreturn [];
阅读全文
1 0
- thinkphp5错误:类型错误: Argument 1 passed to think\Hook::import() must be of the type array
- 报错解决Argument 1 passed to model::get***() must be an instance of Entity_hotel, instance
- The type of the expression must be an array type but it resolved to Point
- Phalcon错误:Argument 1 passed to Phalcon\Mvc\Model::validate()...
- Magento: Recoverable Error: Argument 1 passed to Mage_Core_Model_Store :: setWebsite() must be an in
- Argument must be non-nil 断言错误
- Ogre出现”…The minimum corner of the box must be less than or equal to maximum corner”错误
- 错误:Element type "select" must be declared.
- UIImagePickerController Source type must be UIImagePickerControllerSourceTypeCamera错误
- 警告The argument of type String[] should explicitly be cast to Object[] for the invocation of the vara
- VS2010:error C3083: 'Windows': the symbol to the left of a '::' must be a type
- VS2010:error C3083: 'Office': the symbol to the left of a '::' must be a type
- Python错误:AssertionError: group argument must be None for now
- Python之Headers value 1 must be of type str or bytes, not <class 'int'>错误的解决
- ThinkPHP5错误解析之variable type error:array
- ThinkPHP5错误解析之variable type error:array
- java错误提示------ The public type must be defined in its own file
- JAVA错误:The public type *** must be defined in its own file***
- jquery给input赋值val(val)
- 实现二叉树的前序/中序/后序递归、非递归遍历
- Ubuntu使用apt-file解决库或者文件缺失依赖
- 设置线程池的大小
- 关于Node.js的httpClieint请求报错ECONNRESET的原因和解决措施
- thinkphp5错误:类型错误: Argument 1 passed to think\Hook::import() must be of the type array
- 剑指offer题解C++【1】
- utf-8与utf-8+bom的区别
- Monthly Expense POJ
- MAC 创建U盘启动盘命令
- dubbo入门
- 查找 二(二叉排序树、平衡二叉树、)
- 电流反馈和电压反馈的判断
- 合并有序数组