CodeIgniter Forums
Loading Custom Config when CI_Controller not loaded - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Loading Custom Config when CI_Controller not loaded (/showthread.php?tid=50371)



Loading Custom Config when CI_Controller not loaded - El Forum - 03-24-2012

[eluser]Unknown[/eluser]
I am trying to extend CI_Log and want to be able to load a config file but I am having trouble using get_instance() so I can load the config file. Getting this error:

Fatal error: Class 'CI_Controller' not found in .../system/core/CodeIgniter.php on line 231

Here is my code

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Log extends CI_Log {
        private $enable_syslog = false;

        public function __construct()
        {  
                parent::__construct();
                $this->ci =& get_instance();
                $this->config->load('syslog');
                if($this->config->item('syslog_enable_logging') === true)
                {
                     $this->enable_syslog = true;
                }
        }  
}
?>

Is this possible to load config in this file or will I just need to find another way?

Thanks


Update: Been using codeigniter so long, I forgot about old fashion require
Code:
require_once(APPPATH . 'config/syslog.php');