Reputation: 273
I want to extend CI_Controller
as a base class for my other classes according do my own need.
I read the user guid. Acted as what it told me.
I created application core:
./application/core/MY_ControllerPermission.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_ControllerPermission extends CI_Controller
{
function __construct()
{
parent::__construct();
}
}
And this is my controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if(class_exists('MY_ControllerPermission'))
echo 'clase does exist';
else
echo 'clase does not exist';
class Users extends MY_ControllerPermission
{
....
In my config file:
$config['subclass_prefix'] = 'MY_';
It just show blank page and "clase does not exist"
So where is the problem?
UPDATE
If I add this line:
include_once(APPPATH . 'core/MY_ControllerPermission.php');
before my controller, it would work. Doesn't CodeIgniter load core PHP files automatically?
Upvotes: 2
Views: 3116
Reputation: 102745
Rename MY_ControllerPermission.php
to MY_Controller.php
and you should be good to go.
You can leave everything else the same, you don't even need to use the name MY_Controller
for your class if you don't want to.
Upvotes: 2