PHP code example of enochzg / yii2-mosquitto

1. Go to this page and download the library: Download enochzg/yii2-mosquitto library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

enochzg / yii2-mosquitto example snippets


'components' => [
    'mosquitto' => [
        'class' => 'enochzg\mosquitto\Mosquitto',
        'host' => '127.0.0.1',
        'port' => '1883',
        'keepalive' => 60,
        'cafile' => '[your/cert/path]/ca.crt',
        'certfile' => '[your/cert/path]/client.crt',
        'keyfile' => '[your/cert/path]/client.key',
    ],
    //......
]

yii::$app->mosquitto->publish('1', 'message', 2);