Codeigniter网站工作在MAMP,但不是LAMP


Codeigniter site working in MAMP but not LAMP

我使用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();

问题继续

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

你的问题源于这行:

$this->user_model->do_something();

应该是:

$this->User_model->do_something();

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

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