Reputation: 1472
So basically, the below is the code I have right now:
class MY_Log extends CI_Log {
/**
* Variable storing the CodeIgniter instance.
*
* @access private
* @since v0.1.0.0
*/
private $CI;
/**
* Constructor for later use by internal
* methods.
*
* @access public
* @since v0.1.0.0
*/
public function __construct()
{
// Extend the parent logging.
parent::__construct();
$this->$CI =& get_instance();
}
}
And I get the following error;
Fatal error: Class 'CI_Controller' not found in /<deleted>/system/core/CodeIgniter.php on line 233
This is kinda how the user guide describes it.
Upvotes: 2
Views: 11094
Reputation: 34556
In case this helps anyone, I had the same problem and noticed that it occurred only on URLs that contained a +
in them, e.g. as part of a permalink. CI went haywire; I prevented +
signs from appearing in URLs, and all was well.
Upvotes: 0
Reputation: 954
I guess this error occurs when a log library function is called before CI_Controller class is loaded. This could happen in an early stage of your application routine. So you should extend the log library without using $this->$CI =& get_instance();
.
Upvotes: 4
Reputation: 170
Try putting this at the top of MY_Log.php if you haven't already:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
It's possible that your class MY_Log isn't actually being parsed by php if it's not included in the php delimiters. If that's the case, then CI would see the file MY_Log.php, and expect CI_Log to be extended by the class declared in MY_Log.php. But, if your class isn't within PHP delimiters, CI_Log wouldn't actually be extended, which could cause odd errors.
Upvotes: 0
Reputation: 25435
Quite strange. I just replicated your case (with the info provided) and I encountered no problems. But make sure of a couple things:
application/libraries/My_log.php
You call the library in your controller as
$this->load->library('log');
$this->log->do_something();
i.e, not using "My_log" but the parent library's name. In fact, you're extending it, not creating a different one, so CI wants you to call it the same as the original
Your original file has the following line correctly written (without the $ sign before CI)
$this->CI =& get_instance();
My test case with your code provided works fine on my development machine (Windows 7 WAMP php 5.3.8). I'll be waiting for more infos.
Upvotes: 3