![]() |
[SOLVED]Class as Library - 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: [SOLVED]Class as Library (/showthread.php?tid=77983) |
[SOLVED]Class as Library - pippuccio76 - 11-15-2020 HI , i try to use this class : https://github.com/bluerhinos/phpMQTT as library . I change class name as PhpMQTT and load the library : Code: $params = array('address' => $server, 'port' => $port ,'clientid' => $client_id ); but when i call a method of library i have : Message: Undefined property: Ajax_call_device::$phpMQTT on line 283 this is the 283 line : if ($this->phpMQTT->connect(true, NULL, $username, $password)) How can i solve ? RE: Class as Library - InsiteFX - 11-15-2020 If you change the name of the class you need to change it where ever it is called also. So all those errors if you look at them they have the wrong class name because you changed it. RE: Class as Library - pippuccio76 - 11-16-2020 (11-15-2020, 02:00 PM)InsiteFX Wrote: If you change the name of the class you need to change it where ever it is called also. The class (library ) are correctly loaded , i have not error in the row where i load it... I see that the class are loaded either with PhpMQTT and phpMQTT (because i havent error , if i add a letter as APhpMQTT i have Unable to load the requested class: APhpMQTT instead ) But ever the same error (on console with ajax) : Message: Undefined property: Ajax_call_device::$phpMQTT in this row : if ($this->phpMQTT->connect(true, NULL, $username, $password)) { RE: Class as Library - InsiteFX - 11-16-2020 Your two errors undefind properties are the naming of the class find those two method's and change them to match the library class name. RE: Class as Library - pippuccio76 - 11-16-2020 (11-16-2020, 06:13 AM)InsiteFX Wrote: Your two errors undefind properties are the naming of the class find those two method's and Find the error , class must be only First letter upper case and other lowercase , but in documentation are not explained |