php - Codeigniter autoload controller not working -


i have various controller core/ folder named core/my_controller.php , other controllers in libraries/ folder libraries/user_controller.php,libraries/frontend_controller.php. using code below in config.php autoload these files. dont think working.

i seeing error message fatal error: class 'my_controller' not found in /home/manumakeadmin/manumake.com/2d/application/libraries/frontend_controller.php on line 3

function __autoload($classname) {      if (strpos($classname, 'ci_') !== 0) {         $file = apppath . 'libraries/' . $classname . '.php';         if (file_exists($file) && is_file($file)) {             @include_once($file);         }     } } 

edit

i can make work manually including files as

<?php include_once apppath.'core/my_controller.php';  class frontend_controller extends my_controller { 

but wondering if make autoload code work

library file names , class names must match , capitalised - frontend_controller.php

when extending core class, file name must match class name. capitalise prefix , first letter of class name in file: my_controller.php prefix can set in: application/config/config.php

also ensure files in application directory, rather system. seems case, it's worth checking.

it's idea check user guide naming conventions. example, model class names must have first letter capitalised , rest lowercase; file name should lower case , match class name.


however, it's important realise libraries in codeigniter aren't intended extending core classes, example ci_controller, assume my_controller extending. libraries should used to:

  • create entirely new libraries.
  • extend native libraries.
  • replace native libraries.

i think it's frontend_controller better located in: application/controllers/


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -