【问题标题】:Troubleshooting codeigniter "Unable to locate the model you have specified..." error排查codeigniter“无法找到您指定的模型...”错误
【发布时间】:2015-04-14 21:10:39
【问题描述】:

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

An Error Was Encountered

Unable to locate the model you have specified: Ion_auth_model

这里的所有帖子似乎都是文件放置或文件名或类名的大小写。我已经四次检查了 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');

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

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

谁能指出我正确的方向来解决这个问题????

【问题讨论】:

  • 在库中,echo APPPATH; 产生了什么?
  • 回显 APPPATH;返回“/home/whiteatom/new-app/application/” - 我的应用程序文件夹的正确路径。
  • 确保您的文件名格式正确。类文件名必须是 Ucfirst,其他所有内容都必须小写。在你的情况下 Ion_auth_model.php 而不是“ion_auth_model”
  • 我所有的模型都有小写的文件名,带有 ucfirst 类名。这不正确吗??
  • 如果您使用的是 codeigniter 3,那么文件名应该以大写开头。

标签: php codeigniter module ion-auth codeigniter-3


【解决方案1】:

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

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

它对我有用,请尝试一下...

【讨论】:

    【解决方案2】:

    正如 cmets 中所说:您的模型文件名必须以大写字母开头。在您的情况下,Ion_auth_model.php。

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

    更改了文件命名约定(类文件名现在必须是 Ucfirst 以及其他所有小写字母)。

    【讨论】:

      猜你喜欢
      • 2012-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      相关资源
      最近更新 更多