PHPackages                             oliverlorenz/php-mqtt-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. oliverlorenz/php-mqtt-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

oliverlorenz/php-mqtt-client
============================

a mqtt client library for php

0.5(7y ago)381.4k17[5 issues](https://github.com/oliverlorenz/phpMqttClient/issues)[3 PRs](https://github.com/oliverlorenz/phpMqttClient/pulls)1LGPLPHP

Since May 6Pushed 6y ago9 watchersCompare

[ Source](https://github.com/oliverlorenz/phpMqttClient)[ Packagist](https://packagist.org/packages/oliverlorenz/php-mqtt-client)[ RSS](/packages/oliverlorenz-php-mqtt-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (10)Used By (1)

PHP MQTT Client
===============

[](#php-mqtt-client)

phpMqttClient is an MQTT client library for PHP. Its based on the reactPHP socket-client and added the MQTT protocol specific functions. I hope its a better starting point that the existing PHP MQTT libraries.

[![Build Status](https://camo.githubusercontent.com/7faf89a0ff23b96d9f7d71175424ec989714716aceaebf517e74f9ca9eeb7783/68747470733a2f2f7472617669732d63692e6f72672f6f6c697665726c6f72656e7a2f7068704d717474436c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/oliverlorenz/phpMqttClient)[![Code Climate](https://camo.githubusercontent.com/c699d02e86cf1aad9d7cc5d6e222493d8a4881ae1d32beccbb5f55807048dcd1/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6f6c697665726c6f72656e7a2f7068704d717474436c69656e742f6261646765732f6770612e737667)](https://codeclimate.com/github/oliverlorenz/phpMqttClient)[![Test Coverage](https://camo.githubusercontent.com/8bda33158bb75da5d2764f0b7ae14c4496441d969ee54a251bcfc70a8289b64f/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6f6c697665726c6f72656e7a2f7068704d717474436c69656e742f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/oliverlorenz/phpMqttClient/coverage)

Goal
----

[](#goal)

Goal of this project is easy to use MQTT client for PHP in a modern architecture without using any php modules. Currently, only protocol version 4 (mqtt 3.1.1) is implemented.

- Protocol specifications:

Example publish
---------------

[](#example-publish)

```
$config = require 'config.php';

$connector = ClientFactory::createClient(new Version4());

$p = $connector->create($config['server'], $config['port'], $config['options']);
$p->then(function(Stream $stream) use ($connector) {
    return $connector->publish($stream, 'a/b', 'example message');
});
$connector->getLoop()->run();
```

Example subscribe
-----------------

[](#example-subscribe)

```
$config = require 'config.php';

$connector = ClientFactory::createClient(new Version4());

$p = $connector->create($config['server'], $config['port'], $config['options']);
$p->then(function(\React\Stream\Stream $stream) use ($connector) {
    $stream->on(Publish::EVENT, function(Publish $message) {
        print_r($message);
    });

    $connector->subscribe($stream, 'a/b', 0);
    $connector->subscribe($stream, 'a/c', 0);
});

$connector->getLoop()->run();
```

Notice - (May 12th, 2015)
-------------------------

[](#notice---may-12th-2015)

This is library is not stable currently. Its an early state, but I am working on it. I will add more features if I need them. If you need features: please give feedback or contribute to get this library running.

Currently works:

- connect (clean session, no other connect flags)
- disconnect
- publish
- subscribe

Run tests
---------

[](#run-tests)

```
./vendor/bin/phpunit -c ./tests/phpunit.xml ./tests

```

Troubleshooting
---------------

[](#troubleshooting)

### Why does the connect to localhost:1883 not work?

[](#why-does-the-connect-to-localhost1883-not-work)

The answer is simple: In the example is the DNS 8.8.8.8 configured. Your local server is not visible for them, so you can't connect.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~183 days

Recently: every ~122 days

Total

8

Last Release

2750d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/38740130e6b7b0b3710d2735f8613538b7bd3ff01c99a164015bdc036b8c07c4?d=identicon)[oliverlorenz](/maintainers/oliverlorenz)

---

Top Contributors

[![oliverlorenz](https://avatars.githubusercontent.com/u/403147?v=4)](https://github.com/oliverlorenz "oliverlorenz (79 commits)")[![jjok](https://avatars.githubusercontent.com/u/777648?v=4)](https://github.com/jjok "jjok (70 commits)")[![FlXME](https://avatars.githubusercontent.com/u/22281321?v=4)](https://github.com/FlXME "FlXME (1 commits)")

---

Tags

mqttmqtt-clientphpiotmqtt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oliverlorenz-php-mqtt-client/health.svg)

```
[![Health](https://phpackages.com/badges/oliverlorenz-php-mqtt-client/health.svg)](https://phpackages.com/packages/oliverlorenz-php-mqtt-client)
```

###  Alternatives

[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-mqtt/client

An MQTT client written in and for PHP.

4372.1M30](/packages/php-mqtt-client)[binsoul/net-mqtt-client-react

Asynchronous MQTT client built on React

48787.8k24](/packages/binsoul-net-mqtt-client-react)[simps/mqtt

MQTT Protocol Analysis and Coroutine Client for PHP

39351.6k9](/packages/simps-mqtt)[workerman/mqtt

22450.3k12](/packages/workerman-mqtt)[openswoole/core

Openswoole core library

181.1M32](/packages/openswoole-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
