I’m trying to create a library (in application/libraries) but I’m having problems when I call it from the controller.
Below is the code in the controller
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Client extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->library('security');
}
function index() {
try {
$activation_code = 'aa';
$this->security->Check_User_By_ValidationCode($activation_code);
} catch (Exception $e) {
log('error', $e->getMessage());
}
}
}
?>
And this is what I have in the library
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Security {
var $CI;
public function __construct()
{
$this->CI =& get_instance();
}
public function Check_User_By_ValidationCode($activation_code) {
return $activation_code ;
}
}
?>
But I’m getting a “HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request.” in Chrome.
I’m not able to get anything from logs so I can’t tell what I’m doing wrong here.
Any clues?
Thanks
You cannot use the class
securitybecause that class is defined by CodeIgniter. Just change the name to something else, like “Auth” or something more descriptive.See: http://ellislab.com/codeigniter/user_guide/libraries/security.html