【问题标题】:Codeigniter site working in MAMP but not LAMPCodeigniter 站点在 MAMP 中工作,但不在 LAMP 中
【发布时间】:2015-08-03 22:17:20
【问题描述】:

我正在使用 MAMP 在本地托管我的 codeigniter 项目。我的每个控制器都扩展了 MY_Controller。 MY_Controller 如下所示:

class MY_Controller extends CI_Controller {

    public function __construct()
    {
          parent::__construct();

          $this->load->model('user_model');
          $this->user_model->do_something();
    }
}

在我的 macbook 上使用 MAMP,效果很好。但是,当我将网站上传到运行 apache 的 linux 服务器时,出现以下错误:

Unable to locate the model you have specified: User_model

为什么?

更新

我把大写改成这样:

$this->load->model('User_model');
$this->User_model->do_something();

问题还在继续

【问题讨论】:

  • 尝试更改模型文件的名称以适应消息中的大小写。

标签: php codeigniter mamp lamp


【解决方案1】:

Linux 是一个区分大小写的操作系统,因此在 Windows 上开发和部署到 Linux 时需要非常小心。

您的问题源于以下一行:

$this->user_model->do_something();

应该是:

$this->User_model->do_something();

因为它是您尝试访问的对象的名称。

加载它的那一行很好,因为 CodeIgniter 不介意您使用哪种情况来加载模型,但是 PHP 在 Linux 上在涉及事物名称时会变得有些挑剔。

【讨论】:

  • 我更改了大小写,问题仍然存在。它适用于我运行 MAMP 的 mac,但它在 linux 中给了我相同的错误消息。
猜你喜欢
  • 2014-01-09
  • 1970-01-01
  • 2021-11-14
  • 1970-01-01
  • 1970-01-01
  • 2018-07-19
  • 2023-03-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多