User class not found - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: User class not found (/showthread.php?tid=63462) Pages:
1
2
|
User class not found - helmut - 11-02-2015 Hello, in the folder *application/libraries* I installed a script "Utilities.php", with a class "Utilities". Instancing the class is no problem, also reflection displays all methods. but when I pass the object to the constructor of another class, I get the strange error Severity: Error Message: Class 'CI_Utilities' not found Filename: core/Common.php Line Number: 196 Why does CI create a class CI_Utilities from a user class? What is wrong here? thanx for your help, Helmut RE: User class not found - sv3tli0 - 11-02-2015 How do you load this class in your code? with load->library('Utilities') or autoload ? 1 advice - to prevent duplication of CI Class names try adding prefix or suffix to your class : Utilities_library.. RE: User class not found - helmut - 11-02-2015 (11-02-2015, 08:02 AM)sv3tli0 Wrote: How do you load this class in your code? with load->library('Utilities') or autoload ? with: $this->load->library('Utilities'); RE: User class not found - helmut - 11-04-2015 (11-02-2015, 08:02 AM)sv3tli0 Wrote: 1 advice - to prevent duplication of CI Class names try adding prefix or suffix to your class : Utilities_library.. This should only be done if you want to extend native CI-Libraries. https://ellislab.com/codeigniter/user-guide/general/creating_libraries.html Having looked into the sourcecode of Common.php, I have the impression that there is a bug. RE: User class not found - Martin7483 - 11-04-2015 How and to which class are you passing the utilities or user object? Did a quick test with two libraries. One I called Utilities and the second one Test. I then did this: PHP Code: $this->load->library('Utilities'); Got 0 errors with this. So Utilities is not a reserved name within CI nore does CI change it in anyway that I chould see. RE: User class not found - helmut - 11-05-2015 (11-04-2015, 09:14 AM)Martin7483 Wrote: How and to which class are you passing the utilities or user object? Thanks,now I see that the problem is in the instanciation of the other class (Test in your example), which I did not perform correctly. But now after the commands $this->load->library('Test', array($this->utilities)); //here no error occurs -- $vars = get_object_vars($this->Test); var_dump($vars); I get the error Message: Undefined property: Test::$Test and Message: get_object_vars() expects parameter 1 to be object, null given RE: User class not found - pdthinh - 11-05-2015 (11-05-2015, 04:30 AM)helmut Wrote:(11-04-2015, 09:14 AM)Martin7483 Wrote: How and to which class are you passing the utilities or user object? As far as I know, you should use $this->test (in lower case) Also get_object_vars and var_dump should be called outside the Test class. RE: User class not found - Martin7483 - 11-05-2015 (11-05-2015, 04:37 AM)pdthinh Wrote: As far as I know, you should use $this->test (in lower case) @pdthinh is correct it should be PHP Code: $vars = get_object_vars($this->test); // test in lower case! RE: User class not found - helmut - 11-07-2015 (11-05-2015, 04:48 AM)Martin7483 Wrote:(11-05-2015, 04:37 AM)pdthinh Wrote: As far as I know, you should use $this->test (in lower case) Unfortunately the error occurs in either version, lower AND upper case RE: User class not found - Martin7483 - 11-09-2015 Have you found a solution? |