Skip to content

Commit 0d02dcd

Browse files
authored
Update README.md
1 parent f6dd669 commit 0d02dcd

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

README.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,50 @@
1-
# laravel-mqtt
1+
# laravel-mqttx
22

33
A simple Laravel MQTT client provides Publish/Subscribe methods.
44

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).
66

77
Once the configuration is complete, it is ready to use.
88

9-
The install ``composer require jzzoo/laravel-mqttx``
9+
## install
1010

1111

12+
```php
13+
$ composer require jzzoo/laravel-mqttx -vvv
14+
$ php artisan vendor:publish
15+
```
16+
17+
## config
18+
19+
config/mqttx.php
1220

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:
1435
```php
1536

1637

1738
$mqtt = new Mqttx();
1839

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+
2143

22-
// 订阅
23-
$mqtt->Subscribe('test/demo', function ($topic, $message){
44+
// Subscribe to test/topic topic
45+
$mqtt->Subscribe('test/topic', function ($topic, $message) {
2446
dump($topic);
2547
dump($message);
2648
});
2749

28-
```
50+
```

0 commit comments

Comments
 (0)