CodeIgniter Extended Core Controller

和自甴很熟 提交于 2020-01-25 21:32:07

问题


I'm stumped on this one.

With my CodeIgniter application set up on a WAMP server locally, everything is fine. All of my classes extend my controller (MY_Controller)

However, when the application is on the live environment which is Linux based, it throws an error that the MY_Controller class doesn't exist.

Have I forgot about a configuration variable somewhere or something like that with a path to the application/core folder?

I've looked for other threads with the same issue across Google, found a solution that worked for most people of using parent::Controller(); instead of parent::__construct() but that doesn't resolve this for me.


回答1:


Is it possible that the case of the filename is incorrect (ex: My_controller instead of My_Controller) and your online environment is case sensitive and your local environment is case_insensitive. I've had that problem a lot




回答2:


Sorry for resurrecting an old post but this issue plagued me a little while ago.

I figured I'd add this link: codeigniter MY_Controller not found

Just in-case there is a poor soul who's banging their head against the table and they haven't come across the above post before.

Thanks to Maxime Morin and Phil Sturgeon:

function __autoload($class)
{
    if (strpos($class, 'CI_') !== 0)
    {
        if (file_exists($file = APPPATH . 'core/' . $class . EXT))
        {
            include $file;
        }
    }
} 


来源:https://stackoverflow.com/questions/16898601/codeigniter-extended-core-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!