File tree Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Original file line number Diff line number Diff line change 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.
You can’t perform that action at this time.
0 commit comments