MY_Controller class not found

后端 未结 3 1131
予麋鹿
予麋鹿 2021-01-28 18:43

The main thing i want to solve is to check user session when somebody want to access admin panel. I\'ve created MY_Controller class and placed it in library.

cla         


        
相关标签:
3条回答
  • 2021-01-28 18:57

    I got this error on a project as I'm learning CodeIgniter. My solution was to, to use your project as an example, require_once('MY_Controller'); at the top my new Controller.

    That way I didn't have to move my file to the core and I could keep it in my directory of Controllers.

    0 讨论(0)
  • 2021-01-28 19:04
    1. You need to extend the CI_Controller class instead of CI_Session
    2. You should place MY_Controller under application/core/ folder instead of application/library
    0 讨论(0)
  • 2021-01-28 19:11

    Codeigniter introduced a new folder called core where the libraries that doesn't require loading lives. The original CI_Controller class is one of them, so if you want the automagick pick up your MY_Controller.php file you should place it under application/core too.

    When in doubt, check the extended class's original version under system directory and mirror that under application.

    (Also in your first code example, i think you meant to extend CI_Controller not CI_Session)

    0 讨论(0)
提交回复
热议问题