Skip to content

Commit 9121599

Browse files
authored
Update README.md
1 parent c8eb5e0 commit 9121599

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,49 @@
11
# php-mqtt-client
2-
MQTT v3.1 client in PHP
2+
MQTT 3.1.1 Client with SSL support in PHP
3+
4+
# Installation
5+
6+
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
7+
8+
Either run
9+
10+
php composer.phar require --prefer-dist karpy47/php-mqtt-client
11+
12+
or add
13+
14+
"karpy47/php-mqtt-client": "*"
15+
16+
to the require section of your composer.json.
17+
18+
# Requirements
19+
20+
Should work with all recent PHP versions.
21+
22+
Code developed and running in production using PHP v5.6.27
23+
24+
Not tested on PHP v7, please report back!
25+
26+
# Basic Usage
27+
28+
$client = new MQTTClient('mqtt-server.domain.com', 8162);
29+
$client->setAuthentication'mqtt-server.username','mqtt-server.password');
30+
$client->setEncryption('cacerts.pem');
31+
$success = $client->sendConnect(12345); // set your client ID
32+
if ($success) {
33+
$client->sendSubscribe('topic1');
34+
$client->sendPublish('topic2');
35+
$messages = $client->getPublishMessages();
36+
foreach ($messages as $message) {
37+
echo $message['topic'] .': '. $message['message'] . PHP_EOL;
38+
}
39+
$client->sendDisconnect();
40+
}
41+
$client->close();
42+
43+
# Credits
44+
45+
Thanks to bluerhinos/phpMQTT and McFizh/libMQTT.
46+
47+
# License
48+
49+
Released under the MIT License.

0 commit comments

Comments
 (0)