Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]Class as Library
#1

(This post was last modified: 11-18-2020, 01:05 AM by pippuccio76.)

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 );
    $this->load->library('phpMQTT',$params);

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 ?
Reply
#2

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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.

So all those errors if you look at them they have the wrong class name because you changed it.

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)) {

Reply
#4

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 11-16-2020, 06:42 AM by pippuccio76.)

(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
change them to match the library class name.

Find the error , class must be only First letter upper case and other lowercase , but in documentation are not explained
Reply




Theme © iAndrew 2016 - Forum software by © MyBB