NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #2015 most downloaded on Packagist
An MQTT client written in and for PHP.
Latest stable
v2.3.2
Last release 8 months ago
28 Mar 2026
Ships fairly regularly
a new release about every 4 months
Nearly every release is documented
notes for 28 of 29 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
30 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
Fix deprecation of SplObjectStorage::attach/detach in PHP 8.5 by @dora38 in https://github.com/php-mqtt/client/pull/223
<!-- Release notes generated using configuration in .github/release.yml at master -->
Full Changelog: https://github.com/php-mqtt/client/compare/v2.3.1...v2.3.2
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
Full Changelog: https://github.com/php-mqtt/client/compare/v2.3.0...v2.3.1
Your coding agent can read these notes before it upgrades. Set up the MCP server →
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
Full Changelog: https://github.com/php-mqtt/client/compare/v2.2.0...v2.3.0
Fix: PHP 8.4 - Implicitly nullable parameter declarations deprecated by @StevenFV in https://github.com/php-mqtt/client/pull/192
<!-- Release notes generated using configuration in .github/release.yml at master -->
Full Changelog: https://github.com/php-mqtt/client/compare/v2.1.0...v2.2.0
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
Full Changelog: https://github.com/php-mqtt/client/compare/v2.0.0...v2.1.0
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
Full Changelog: https://github.com/php-mqtt/client/compare/v1.8.1...v2.0.0
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
Full Changelog: https://github.com/php-mqtt/client/compare/v1.8.0...v1.8.1
Add connected event handler by @UtechtDustin in https://github.com/php-mqtt/client/pull/152
Full Changelog: https://github.com/php-mqtt/client/compare/v1.7.1...v1.8.0
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
Full Changelog: https://github.com/php-mqtt/client/compare/v1.7.0...v1.7.1
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
Full Changelog: https://github.com/php-mqtt/client/compare/v1.6.0...v1.7.0
Add new connection setting for delay between reconnect attempts by @Namoshek in https://github.com/php-mqtt/client/pull/130
Full Changelog: https://github.com/php-mqtt/client/compare/v1.5.0...v1.6.0
Fix: Local test setup uses port 1884 for MQTT with authentication by @Namoshek in https://github.com/php-mqtt/client/pull/127
Full Changelog: https://github.com/php-mqtt/client/compare/v1.4.0...v1.5.0
Explanation for #128: The matched wildcards are now passed as fourth parameter to the subscription callback:
$mqtt->subscribe('foo/+/bar/#', function ($topic, $message, $retained, $matchedWildcards) {
echo sprintf("Received message on topic [%s]: %s\n", $topic, $message);
echo sprintf("Matched wildcards: %s\n", json_encode($matchedWildcards));
}, 0);
// Received message on topic [foo/baz/bar/hello/world/42]: hello world!
// Matched wildcards: ["baz", "hello/world/42"]
Run some integration tests with authentication by @Namoshek in https://github.com/php-mqtt/client/pull/113
loopOnce() method in a class extending MqttClient, this change is fully backwards compatible ✔️Full Changelog: https://github.com/php-mqtt/client/compare/v1.3.0...v1.4.0
_✔️ This release does not contain any backwards incompatible changes._
✔️ This release does not contain any backwards incompatible changes.
Full Changelog: https://github.com/php-mqtt/client/compare/v1.2.0...v1.3.0
In #90, support for MQTT 3.1.1 has been added a few months ago. Since the implementation has not received any negative feedback, it seems to work as e
In #90, support for MQTT 3.1.1 has been added a few months ago. Since the implementation has not received any negative feedback, it seems to work as expected and is hereby released.
There MQTT 3.1.1 protocol can be used by passing 3.1.1 as fourth parameter to the constructor, e.g. using the provided constant:
$mqtt = new \PhpMqtt\Client\MqttClient($server, $port, $clientId, \PhpMqtt\Client\MqttClient::MQTT_3_1_1);
Since more and more composer packages are relying on v3 of psr/log, this PR adds fully backwards compatible support for it in #94. This is possible be
Since more and more composer packages are relying on v3 of psr/log, this PR adds fully backwards compatible support for it in #94. This is possible because the Logger is marked as @internal.
Since more and more composer packages are relying on v2 of `psr/log`, this PR adds fully backwards compatible support for it in #92.
Since more and more composer packages are relying on v2 of psr/log, this PR adds fully backwards compatible support for it in #92.
This release provides a fix for hanging connection attempts after successfully opening a socket connection (#84). This may happen when connecting to b
This release provides a fix for hanging connection attempts after successfully opening a socket connection (#84). This may happen when connecting to brokers running in a container, where the application has not bound the forwarded socket yet. The connection handshake is now aborted after the configured connection timeout.
As part of #75, support for shared subscriptions has been added. Even though this is an MQTT 5 feature, all common brokers seem to support it for MQTT
As part of #75, support for shared subscriptions has been added. Even though this is an MQTT 5 feature, all common brokers seem to support it for MQTT 3.1 connections as well. This means that connecting with multiple clients using a topic of the form $share/<group>/<topic> will have the broker distribute messages to all of those clients where the group name is the same. More details about shared subscriptions can be found on the HiveMQ blog.
With this release, long awaited features are finally here. Not only is there now full support for all TLS options offered and supported by PHP SSL con
With this release, long awaited features are finally here. Not only is there now full support for all TLS options offered and supported by PHP SSL contexts. Also, a lot of work has been put into refactoring and testing of existing code. A few APIs have been moved and renamed, and there is now also an extensive collection of examples available in the php-mqtt/client-examples repository.
A full list of changes can be found in the changelog. It should give a good idea how to upgrade as well. Upgrading is recommended.
Special thanks go to @thg2k for contributing to this version in various ways!
Significant improvements to the architecture, API and design of the library have been part of v1.0.0.
Upgrading should be rather simple for most users though, since the public API has not changed a lot
and only in places which are not used too frequently.
A lot of effort has been put into this summary to document as many changes as possible. It is impossible to give a guarantee about the completeness of this list though. You should cover your uses of the library with tests yourself as well.
The following summary compares v0.3.0 to v1.0.0.
\PhpMqtt\Client\Contracts\MQTTClient → \PhpMqtt\Client\Contracts\MqttClient\PhpMqtt\Client\MQTTClient → \PhpMqtt\Client\MqttClient\PhpMqtt\Client\Exceptions\MQTTClientException → \PhpMqtt\Client\Exceptions\MqttClientExceptionMQTTClient class to a new interface \PhpMqtt\Client\Contracts\MessageProcessor and the respective implementation for MQTT 3.1, \PhpMqtt\Client\MessageProcessors\Mqtt31MessageProcessor.
MessageProcessor is responsible for parsing and building packages on a byte level.protected properties have been changed to private to ensure they are not manipulated outside the offered scope, which is enforced through getters and setters. This change only affects users which actively inherited their own implementation from the library.$caFile parameter of the MQTTClient constructor as well as the $username and $password parameters of the MQTTClient::connect() method have been moved to the ConnectionSettings class.ConnectionSettings use fluent setters for configuration now (see README).ConnectionSettings`` passed to MQTTClient::connect()are now validated and may not contain invalid configuration. In case of invalid configuration, a\PhpMqtt\Client\Exceptions\ConfigurationInvalidException` is thrown.ConnectionSettings to support more uses cases with secured connections.\PhpMqtt\Client\Exceptions\RepositoryException if an interaction with the repository fails. This should happen with the MemoryRepository only in exceptional situations, but when implementing persisted repositories, this may happen more frequently and should therefore be considered.MQTTClient::connect() method had a parameter called $sendCleanSessionFlag while the MqttClient::connect() method has the same parameter, but called $useCleanSession. The parameters $username and $password have been removed entirely and are now part of the ConnectionSettings.MQTTClient::close() has been renamed to MqttClient::disconnect().$topic of MQTTClient::subscribe() has been renamed to $topicFilter to reflect its meaning (which is a topic, but with wildcards). The $callback parameter can be null now and has null as default.$topic of MQTTClient::unsubscribe() has been renamed to $topicFilter as well.\PhpMqtt\Client\Exceptions\MqttClientException as base. You should ensure your calls to methods of the MqttClient handle the exceptions appropriately.\PhpMqtt\Client\MQTTClient class have been moved to the respective exception classes. This change only affects you if you used these constants to render detailed exception information for your users.\PhpMqtt\Client\Contracts\Repository interface has been changed significantly and summarizing all changes would be quite hard anyway. We therefore encourage you to have a look at the interface again and update your own implementation(s) of it, if you have any.\PhpMqtt\Client\Logger implementation of Psr\Log\LoggerInterface does now decorate the log output with details about the MQTT client (format: MQTT [{host}:{port}] [{clientId}] {message}).localhost:1883 (or the configuration in phpunit.xml is changed instead).MqttClient::isConnected(): returns true if a connection is established (socket opened), and false otherwise.MqttClient::getReceivedBytes(): returns the number of raw bytes received from the broker (this includes meta information and not only message contents).MqttClient::getSentBytes(): returns the number of raw bytes sent to the broker (this includes meta information and not only message contents).No functionality has been removed in this version.
With this release, long awaited features are finally here. Not only is there now full support for all TLS options offered and supported by PHP SSL con
With this release, long awaited features are finally here. Not only is there now full support for all TLS options offered and supported by PHP SSL contexts. Also, a lot of work has been put into refactoring and testing of existing code. A few APIs have been moved and renamed, and there is now also an extensive collection of examples available in the php-mqtt/client-examples repository.
A (preliminary) full list of changes can be found in the CHANGELOG.md.
If you have the time, please upgrade your application to this version and give feedback how it works for you. In about a week, a final version v1.0.0 will be published if everything goes by plan.
With this release, support for client certificates has been added. It is now possible to use a client certificate with an encrypted or unencrypted key
With this release, support for client certificates has been added. It is now possible to use a client certificate with an encrypted or unencrypted key by providing the full path to the certificate and key files. The new settings are available through optional arguments of the ConnectionSettings. The addition is fully backwards compatible and updates should work without issues. Details about this change can be found in #41.
When the MQTT client was used to subscribe to topics using QoS 2, it would not be able to receive messages with QoS 2 but only messages with lower QoS
When the MQTT client was used to subscribe to topics using QoS 2, it would not be able to receive messages with QoS 2 but only messages with lower QoS. This is because no PUBREL message was sent in response to received PUBREC messages, producing some sort of dead lock in the client-server communication. Details can be found in #37.
Major improvements regarding new TLS options have been made in #24. It is now possible to use TLS without providing a CA file and peer verification ca
Major improvements regarding new TLS options have been made in #24. It is now possible to use TLS without providing a CA file and peer verification can be toggled based on individual needs. Also establishing the connection should now be more reliable, since first a normal TCP connection is established, for which then TLS is enabled afterwards based on the defined settings. Note: for backwards compatibility, $useTls of the connection settings is also enabled if a CA file is configured.
For use cases with an external loop, where the MQTT client is run besides some other code, a new protected getter nextPingAt() has been added to the MQTTClient class. If you need access to this method, you should inherit your own client implementation. Details can be found in #21.
To avoid busy waiting when reading from the socket connection in blocking mode, the configured $socketTimeout is now taken into account and the readFromSocket($limit, $withoutBlocking) method will exit with an exception after the configured amount of seconds. The changes are quite compact and can be found in #29.
The way message contents (e.g. topic names) were encoded when publishing messages and subscribing to topics could lead to issues in previous versions. #30 fixes this by always encoding messages according to the specification.
Last but not least, some parts of the code have been normalized in respect of code style (#22). A consistent code style for pull requests is now enforced using a workflow (#23).
As pointed out and fixed in #19, the retain flag sent by the broker has not been passed to subscription callbacks. This flag indicates whether a messa
As pointed out and fixed in #19, the retain flag sent by the broker has not been passed to subscription callbacks. This flag indicates whether a message is received because it has been retained by the broker or if it was delivered live (in case of $retained === false), after subscribing to a topic. Having this information can be used to detect stale messages for example. A good summary on retained messages can be found on the HiveMQ blog.
Due to the change made in #9, it is now possible to access the raw socket from own implementations of the MQTTClient when using inheritance. This may be handy if one needs to work with multiple clients and stream_select().
Minor changes to the code style have been pushed in #20.
As pointed out in #6, when using a username and password to connect to a broker, the message size has been manipulated using string concatenation inst
As pointed out in #6, when using a username and password to connect to a broker, the message size has been manipulated using string concatenation instead of mathematical addition. This caused an issue with chr() expecting an integer and not a string. It also would have lead to wrong information being sent.
Usernames and passwords should now be correctly encoded during the connection handshake. Thanks to @sten for pointing out this oversight!
The MQTT v3.1 specification states that clients need to send at least one data-related message within the defined _Keep Alive Interval_ (which is retu
The MQTT v3.1 specification states that clients need to send at least one data-related message within the defined Keep Alive Interval (which is returned by the broker during the connection handshake). If no such message has been sent, the client MUST send a PINGREQ instead. Otherwise, the broker closes the connection.
Due to the way the MQTT client was resetting the ping timer whenever a message was received from the broker, subscribe-only applications utilizing the QoS Level 0 could run into disconnects. This happened because the client never sent an acknowledgement for the QoS 0 messages and also never sent a Ping Request because the Keep Alive Timer was reset on every received published messages.
This patch fixes the issue by resetting the Keep Alive Timer only whenever data is sent to the broker. More details in #5.
Unfortunately, PHP will simply throw a PHP notice (which cannot be catched) when we use fwrite() on a socket and the connection has been closed by the
Unfortunately, PHP will simply throw a PHP notice (which cannot be catched) when we use fwrite() on a socket and the connection has been closed by the server. To leverage the already in place error handling of the MQTTClient, we suppress potential PHP notices, warnings and errors when using fwrite().
In this release, an issue with declare(strict_types=1) has been fixed. Constructing a new MQTTClient instance without the $clientId argument caused a
In this release, an issue with declare(strict_types=1) has been fixed. Constructing a new MQTTClient instance without the $clientId argument caused a unique id to be generated. Unfortunately, the generateRandomClientId() method was missing a cast. More details can be found in the PR #1.
Nothing published for this version
One column per quarter.