Welcome Guest, Not a member yet? Register   Sign In
get_instance error - Class 'CI_Controller' not found
#1

In my "helper" function in the "application" folder,

PHP Code:
if ( ! function_exists('_return_config_xxx'))
{
    function 
_return_config_xxx(){

 
       $CI =& get_instance();
    return 
$CI->config->item('config_xxx')
    }



I call :
$ CI = & get_instance ();
return $ CI-> config-> item ('XXX');

and I get the following error:

Code:
Fatal error: Class 'CI_Controller' not found in /home/www/aprendermais.render.com.br/html/system/core/CodeIgniter.php on line 369
A PHP Error was encountered

Severity: Error

Message: Class 'CI_Controller' not found

Filename: core/CodeIgniter.php

Line Number: 369

Backtrace:
Reply
#2

We need more information, like your directory structure where are you calling that function / method from?

If you have moved the application and system folders then you have to edit the index.php file and tell it
where they are located.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

your helper in in application/helpers/ ?
Reply
#4

You're calling this helper prior to controller instantiation (likely in a pre_system hook, or a core library extension), and you can't use get_instance() in that case because what get_instance() does is to return the controller object.
Reply
#5

(10-05-2017, 02:08 AM)Narf Wrote: You're calling this helper prior to controller instantiation (likely in a pre_system hook, or a core library extension), and you can't use get_instance() in that case because what get_instance() does is to return the controller object.

I agree with the above comment.

If you provide the logs, we can have a look.
Reply
#6

(10-05-2017, 02:08 AM)Narf Wrote: You're calling this helper prior to controller instantiation (likely in a pre_system hook, or a core library extension), and you can't use get_instance() in that case because what get_instance() does is to return the controller object.



@Narf


Do you think the same case applies to me?




An uncaught Exception was encountered
Type: Error
Message: Class 'CI_Config' not found
Filename: /home/tauenjic/code.tauenji.com/install/system/core/Common.php
Line Number: 196
Backtrace:
File: /home/tauenjic/code.tauenji.com/install/index.php
Line: 326
Function: require_once



Code below for /home/tauenjic/code.tauenji.com/install/system/core/Common.php Pointing to line 196

function &load_class($class, $directory = 'libraries', $param = NULL)
{
static $_classes = array();

// Does the class exist? If so, we're done...
if (isset($_classes[$class]))
{
return $_classes[$class];
}

$name = FALSE;

// Look for the class first in the local application/libraries folder
// then in the native system/libraries folder
foreach (array(APPPATH, BASEPATH) as $path)
{
if (file_exists($path.$directory.'/'.$class.'.php'))
{
$name = 'CI_'.$class;

if (class_exists($name, FALSE) === FALSE)
{
require_once($path.$directory.'/'.$class.'.php');
}

break;
}
}

// Is the request a class extension? If so we load it too
if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'))
{
$name = config_item('subclass_prefix').$class;

if (class_exists($name, FALSE) === FALSE)
{
require_once(APPPATH.$directory.'/'.$name.'.php');
}
}

// Did we find the class?
if ($name === FALSE)
{
// Note: We use exit() rather than show_error() in order to avoid a
// self-referencing loop with the Exceptions class
set_status_header(503);
echo 'Unable to locate the specified class: '.$class.'.php';
exit(5); // EXIT_UNK_CLASS
}

// Keep track of what we just loaded
is_loaded($class);

$_classes[$class] = isset($param)
? new $name($param)
: new $name();     <<--        <<--           <<--        <<<-- LINE 196
return $_classes[$class];
}

Attached Files
.html   overal_errors.html (Size: 6.14 KB / Downloads: 1)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB