开发者

Using CodeIgniter Profiler

I'm struggling to enable the profiler in CodeIgniter. I've added it to the $libraries config array so it should be auto loaded. But I'm getting the error...

Fatal error: Call to a member function enable_profiler() on a non-object in C:\......\application\core\publiccontroller.php on line 6

My code is:

<?php
class PublicController extends CI_Controller {
    public function __construct () {
        // enable profiler for development
        if (ENVIRONMENT == 'development') {
            $this->output->enable_profiler(true);
        }
    }
}
?>

autoload.php has....

/*
|开发者_如何转开发 -------------------------------------------------------------------
|  Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in the system/libraries folder
| or in your application/libraries folder.
|
| Prototype:
|
|   $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/

$autoload['libraries'] = array('profiler');

What am I doing wrong? I'm using CI version 2


Just as a note: this suggestion resolves similar issues in CI 1.x, it is not tested in CI 2. The problem, I suspect is that you're calling that in the constructor before the object has fully initiated itself. Can you confirm $this->load exists? What happens if you put parent::__construct(); as the first line of the constructor?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜