![]() |
problem while adding Custom Libraries to CI3 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: problem while adding Custom Libraries to CI3 (/showthread.php?tid=62310) |
problem while adding Custom Libraries to CI3 - newdev - 07-02-2015 HI, I have a working application in previous version of CI and is working well, i am trying to create a new application with somewhat reuse of previous code, (but it's a new application, not an upgrade), I downloaded the latest zip of CI from website. I setup CI and it worked well, i was able to see the welcome controller, I copied some of my previous helping libraries into libraries directory and included them as Code: $this->load->library('directoryinfo'); but this give me the following error PHP Code: A PHP Error was encountered I am not able to understand , why i am receiving this error, because, in my class there is no "CI_ " in the name. So i need help in this regard Thanks RE: problem while adding Custom Libraries to CI3 - Narf - 07-02-2015 What exactly are the class name and its file name? RE: problem while adding Custom Libraries to CI3 - newdev - 07-02-2015 (07-02-2015, 06:27 AM)Narf Wrote: What exactly are the class name and its file name?Class name as mentioned below Code: class Directoryinfo { RE: problem while adding Custom Libraries to CI3 - Narf - 07-03-2015 OK, then move it out of system/libraries/ and put it in application/libraries/ instead ... you're not supposed to touch the system/ directory. RE: problem while adding Custom Libraries to CI3 - newdev - 07-03-2015 (07-03-2015, 01:24 AM)Narf Wrote: OK, then move it out of system/libraries/ and put it in application/libraries/ instead ... you're not supposed to touch the system/ directorythis library is present inside application/libraries directory , i haven't touched the system/ directory, instead i have checked the common.php and found the code below and you can see that "CI_' is being concatenated with every class name whether it exists in /system/ or /application/ PHP Code: function &load_class($class, $directory = 'libraries', $param = NULL) don't know if there is a fix in the core files, or i am doing something wrong, but the same libraries in the same way worked with previous version and not working on this CI3 RE: problem while adding Custom Libraries to CI3 - Narf - 07-03-2015 Well, neither CI_Loader::library(), nor any method in its stack trace call the load_class() function. And also, line 192 in system/core/Common.php for CI3 is this: Code: is_loaded($class); ... which couldn't possibly trigger the error message that you originally reported. So, you most certainly have made modifications to the system/ directory, even if you didn't put your custom libraries in there. And that doesn't exclude the possibility of you having a MY_Loader override or one of your custom libs calling load_class() itself. RE: problem while adding Custom Libraries to CI3 - newdev - 07-03-2015 (07-03-2015, 02:53 AM)Narf Wrote: Well, neither CI_Loader::library(), nor any method in its stack trace call the load_class() function. And also, line 192 in system/core/Common.php for CI3 is this: i put some echo in the common.php to check the error and what's happening there, so line number might change, as at my side line 192 points to PHP Code: $_classes[$class] = isset($param) and the error is due to the Code: new $name() Also if you might have noticed the following part in the above function that i pasted from Common.php CI_ is being added to all class names whether it's in system or application directory Code: $name = 'CI_'.$class; PHP Code: if (file_exists($path.$directory.'/'.$class.'.php')) and that will make the variable $name to be having value "CI_libraryname" , so that at the initialization point it will always try to initiate the $name(), while that class doesn't exist, due to the addition of "CI_" in the class name RE: problem while adding Custom Libraries to CI3 - Narf - 07-03-2015 I'm very well aware of what load_class() does ... the problem isn't in load_class(), it's that you're calling it from somewhere. And as I said: (07-03-2015, 02:53 AM)Narf Wrote: neither CI_Loader::library(), nor any method in its stack trace call the load_class() function Here's proof if you don't believe me: Quote:$ git checkout 3.0.0 RE: problem while adding Custom Libraries to CI3 - kendysond - 09-04-2015 (07-03-2015, 03:34 AM)Narf Wrote: I'm very well aware of what load_class() does ... the problem isn't in load_class(), it's that you're calling it from somewhere. And as I said: please is there a fix for this unwanted update? i use this feature to share same library with multiple codeigniter installation with one system. |