Welcome Guest, Not a member yet? Register   Sign In
Class Private_Controller not found on linux, but works fine on windows
#1

[eluser]Ehs4n[/eluser]
I am using MY_controller for authentication.

Inside MY_controller, i have two classes, Public_Controller & Private_Controller. Public_Controller extends Controller class and is used to load models, libraries etc while as Private_Controller extends Public_Controller and authenticates user.

The app is working fine on Windows, but is gives following error on Linux.

Fatal error: Class 'Private_Controller' not found in ..... on line 2.

It shows the error in my home controller.

Code in MY_controller

Code:
<?php if (!defined('BASEPATH')) exit('No direct access allowed.');

/**
* Extending base Controller to add custom stuff
* Accessible to all
*/
class Public_Controller extends Controller {
  function Public_Controller() {
    parent::Controller();
    
    $this->load->helper(array('url', 'form', 'date'));

    $this->load->library('session');
    $this->load->library('util');
    $this->load->library('validation');
    $this->load->library('upload');
    
    $this->load->model('user_model', 'userM');
    $this->load->model('student_model', 'studentM');
    $this->load->model('school_model', 'schoolM');
    $this->load->model('parents_model', 'parentsM');
    $this->load->model('guardian_model', 'guardianM');
    $this->load->model('fee_model', 'feeM');
    $this->load->model('util_model', 'utilM');
    $this->load->model('transaction_model', 'transM');
    
    $this->load->database();
    
    $this->data->errors = '';
    $this->data->messages = '';
  }
}

/**
* Extending base Controller to add authentication
* Checks user access
*/
class Private_Controller extends Public_Controller {
  function Private_Controller() {
    parent::Public_Controller();
    if(!$this->session->userdata('user')) {
      redirect('user/login', 'location', 301);
    } else {
      $this->data->head->user = $this->session->userdata('user');
    }
  }
}

Code in home controller

Code:
<?php
class Home extends Private_Controller {
  function Home() {
    parent::Private_Controller();
  }
  
  function index() {
    $this->data->head->title = 'Home';
    $this->load->view('home', $this->data);
  }
}

Please help me.
#2

[eluser]bretticus[/eluser]
In order to extend the native Controller class, shouldn't you have to Prefix it with MY_ also?

From the manual:

Quote:The class declaration must extend the parent class.
Your new class name and filename must be prefixed with MY_ (this item is configurable. See below.).
#3

[eluser]xwero[/eluser]
try MY_Controller instead of MY_controller
#4

[eluser]Ehs4n[/eluser]
I tried to change the name of my class from Public_Controller to MY_Controller and updated same in my home controller, but still it is showing the same error. Now instead of "Class Private_Controller not found", it shows "Class MY_Controller not found" ;(
#5

[eluser]Ehs4n[/eluser]
[quote author="xwero" date="1237381059"]try MY_Controller instead of MY_controller[/quote]

Worked. Thanks Wink
#6

[eluser]eddel[/eluser]
i am experiencing the same problem :-S

i am extending the CI_Controller to MY_Controller, it works fine in my local which is windows based, but when i run it on the linux server it gives an error that Class MY_Controller is not found.

Can anyone help me? :-S




Theme © iAndrew 2016 - Forum software by © MyBB