Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

APPPATH codeigniter doesnt work on server

I have a problem in codeigniter - after I upload it to the server I am requiring a file in a model from libraries folder

<?php
require_once(APPPATH.'libraries/MY_Model.php');
Class scroll_news_model extends MY_model
{
 public function __construct()
 {
    parent::__construct("scroll_news");
 }
}

this code was working fine in my localhost environment but I keep getting this error after I upload it:

Fatal error: require_once() [function.require]: Failed opening required 'application/libraries/MY_Model.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/arab2day/public_html/temp/arab2day/application/models/scroll_news_model.php on line 2

like image 566
Ramy Selim Avatar asked Feb 11 '12 18:02

Ramy Selim


2 Answers

Check the case of your file names; windows makes no difference between ABC.php and abc.php, but linux does.

like image 132
Lepidosteus Avatar answered Sep 30 '22 20:09

Lepidosteus


If you are trying to extend the CI_Model class, MY_Model.php belongs in the /core directory rather than /libraries, and you don't need to include it - it will be loaded automatically when the base model class is loaded.

This is how extending core classes works, extending regular non-essential "libraries" is slightly different. Read more about it here:

http://codeigniter.com/user_guide/general/core_classes.html

As far as the literal problem goes, Lepidosteus makes a good point about case sensitivity and OS, I've run into this issue myself several times.

like image 22
Wesley Murch Avatar answered Sep 30 '22 20:09

Wesley Murch