排查 codeigniter "Unable to locate the model you have specified..." 错误

Troubleshooting codeigniter "Unable to locate the model you have specified..." error

我一直在 Mac 上使用 CodeIgniter 开发 Web 应用程序,没有任何问题。我正在使用 Ion Auth 库进行用户身份验证。我没有将网站移植到生产服务器,我收到以下错误:

An Error Was Encountered

Unable to locate the model you have specified: Ion_auth_model

这里的所有帖子似乎都是文件放置或文件名或 class 名称的大小写。我已经四次检查了 ion auth 模型代码..

/application/models/ion_auth_model.php

class Ion_auth_model extends CI_Model{
   ...
}

加载模型的唯一位置是在 ion auth 库中:

/applicaiton/libraries/ion_auth.php

$this->load->model('ion_auth_model');

最令人沮丧的是 - 它在我的开发系统上完美运行。我的生产环境和开发环境之间的唯一区别是数据库配置(我现在甚至在开发模式下使用它,所以我可能会看到错误。

没有日志条目,页面上没有有用的错误,CodeIgniter 根本没有帮助指导我错误的来源。

任何人都可以指出正确的方向来解决这个问题吗????

正如评论中所说:您模型的文件名必须以大写字母开头。在你的例子中,Ion_auth_model.php。

https://codeigniter.com/userguide3/changelog.html#version-3-0-0

changed filenaming convention (class file names now must be Ucfirst and everything else in lowercase).

你的自动加载配置(application/config/autoload.php)

$autoload['libraries'] = array('ion_auth');

对我有用,请试试...