Welcome Guest, Not a member yet? Register   Sign In
DRY Base Controler


I am playing around with Ion Auth library.
I came across an article from Kyle Noland explaining how to set up base controller performing the identity check.
This was based on Phil Sturgeon article CodeIgniter Base Classes: Keeping it DRY.

It did not work for me: the Secure_Controller would not load, I was getting an error stating it wasn't found !
I had to move the Secure_Controller class declaration to the application/core/My_Controller.php file.

I believe using Base Controller is a fairly common setup: has anyone managed to get this working (without putting all the classes in the MY_Controller.php file) ?

(This is not an Ion Auth problem, this is a loading base controller problem).

[email protected]

(This post was last modified: 10-05-2015, 04:10 PM by InsiteFX.)

You need to add this autoloader to your ./application/config.php file:

PHP Code:
| Autoloader function
| @author Brendan Rehman
| @param $class_name
| @return void
function __autoloader($class_name)
// class directories
$directories = array(
APPPATH 'core/',
// add more autoloading folders here… and you’re done.

// for each directory
foreach ($directories as $directory)
// see if the file exsists
if (file_exists($directory.$class_name '.php'))
$directory.$class_name '.php');
// only require the class once, so quit after to save effort (if you got more, then name them something else



What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Thanks, that did the trick !

Theme © iAndrew 2016 - Forum software by © MyBB