| 
1 |  | -# laravel-mqtt  | 
 | 1 | +# laravel-mqttx  | 
2 | 2 | 
 
  | 
3 | 3 | A simple Laravel MQTT client provides Publish/Subscribe methods.  | 
4 | 4 | 
 
  | 
5 |  | -Source code is mainly based on [phpMQTT](https://github.com/bluerhinos/phpMQTT)  | 
 | 5 | +Source code is mainly based on [phpMQTT](https://github.com/bluerhinos/phpMQTT).  | 
6 | 6 | 
 
  | 
7 | 7 | Once the configuration is complete, it is ready to use.  | 
8 | 8 | 
 
  | 
9 |  | -The install ``composer require jzzoo/laravel-mqttx``  | 
 | 9 | +## install   | 
10 | 10 | 
 
  | 
11 | 11 | 
 
  | 
 | 12 | +```php  | 
 | 13 | +$ composer require jzzoo/laravel-mqttx -vvv  | 
 | 14 | +$ php artisan vendor:publish  | 
 | 15 | +```  | 
 | 16 | + | 
 | 17 | +## config  | 
 | 18 | + | 
 | 19 | +config/mqttx.php  | 
12 | 20 | 
 
  | 
13 |  | -Example:   | 
 | 21 | +```php  | 
 | 22 | +return [  | 
 | 23 | +    'host'     => env('mqtt_host','127.0.0.1'),  | 
 | 24 | +    'password' => env('mqtt_password',''),  | 
 | 25 | +    'username' => env('mqtt_username',''),  | 
 | 26 | +    'certfile' => env('mqtt_cert_file',''),  | 
 | 27 | +    'port'     => env('mqtt_port','1883'),  | 
 | 28 | +    'debug'    => env('mqtt_debug',false),  | 
 | 29 | +    'qos'      => env('mqtt_qos', 0),  | 
 | 30 | +    'retain'   => env('mqtt_retain', 0)  | 
 | 31 | +];  | 
 | 32 | +```  | 
 | 33 | + | 
 | 34 | +## example:   | 
14 | 35 | ```php  | 
15 | 36 | 
 
  | 
16 | 37 | 
 
  | 
17 | 38 | $mqtt = new Mqttx();  | 
18 | 39 | 
 
  | 
19 |  | -// 发布  | 
20 |  | -$mqtt->Publish('test/demo', sprintf("mqtt message: ", mt_rand(10,9999)));  | 
 | 40 | +// Post news to test/topic topic  | 
 | 41 | +$mqtt->Publish('test/topic', sprintf("mqtt message: ", mt_rand(10,9999)));  | 
 | 42 | +     | 
21 | 43 | 
 
  | 
22 |  | -// 订阅          | 
23 |  | -$mqtt->Subscribe('test/demo', function ($topic, $message){  | 
 | 44 | +// Subscribe to test/topic topic         | 
 | 45 | +$mqtt->Subscribe('test/topic', function ($topic, $message) {  | 
24 | 46 |     dump($topic);  | 
25 | 47 |     dump($message);  | 
26 | 48 | });  | 
27 | 49 | 
 
  | 
28 |  | -```  | 
 | 50 | +```  | 
0 commit comments