I developed a small application with Codeigniter and brought it to run with vagrant and Debian. And everything was fine.
So now I'm trying to set up a virtual machine with Xubuntu 15.04. Installed the same packages (PHP as an Apache module)
Now I'm getting the following error:
Unable to locate the model you have specified: Person_model
This is how I load my model:
$this->load->model('person_model');
And this is how my model actually looks like in models/person_model.php
<?php
class Person_model extends CI_Model {
function __construct() {
parent::__construct();
}
// ...
}
On Xubuntu I'm running PHP 5.6.4-4ubuntu6.2 and on Debian I'm running PHP 5.4.41-0+deb7u1
Thanks for any advice and help!
Starting with CodeIgniter 3.0, all class filenames (libraries, drivers, controllers and models) must be named in a Ucfirst-like manner or in other words - they must start with a capital letter. http://www.codeigniter.com/user_guide/installation/upgrade_300.html#step-2-update-your-classes-file-names
This is CodeIgniter 3.0 coding convention which you must follow. So your model file should be models/Person_model.php
.
Probably you use case insentive file system (host OS is like Windows or Mac) with Vagrant shared folder . And you don't use Vagrant shared folder with Xubuntu, don't you?
Anyway, this is problem with file system, not PHP version nor OS.
Alter these settings
Model File name should be - person_model.php
Then in controller
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Resources extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('Person_model');
}
}
And inside person_model.php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Person_model extends CI_Model {
function __construct()
{
parent::__construct();
}
}
This will solve your all problems.
Read This Articles too