Download the PHP package utopia-php/mqtt without Composer

On this page you can find all versions of the php package utopia-php/mqtt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mqtt

Utopia MQTT

[!IMPORTANT] This repository is a read-only mirror of packages/mqtt in appwrite/appwrite. Development happens there — please open issues and pull requests against appwrite/appwrite.

Discord

Utopia MQTT is a PHP toolkit for building MQTT brokers (3.1.1 and 5.0). You implement one interface of typed control packets and the library owns the wire — framing, decoding, per-version encoding, packet ids, the QoS handshake, keep-alive reaping, and subscription matching. This library is maintained by the Appwrite team and is framework-agnostic.

Installation

The library requires PHP 8.2+. The Swoole adapter additionally needs the Swoole extension.

Quick start

Create a broker by wiring an adapter (which transports to listen on) with a handler (how packets are answered). The handler below accepts every client, grants every subscription, and fans each publish out to its subscribers.

The broker listens on TCP port 1883 and speaks both 3.1.1 and 5.0. Implement Handler to add authentication, per-topic authorization, offline delivery, or any policy your broker needs.

Handlers

The Handler is the whole application surface. Each method receives a decoded control packet and returns a decision — itself a packet, which the broker encodes for the client's negotiated version. You never touch bytes, packet ids, or version encoders.

Authenticate a CONNECT by returning a Connack (v5 enhanced auth may return an Auth challenge instead):

Authorize each subscribed filter, granting a QoS or denying it:

Delivery is yours. onPublish receives the local subscribers the broker matched; publish to each Connection, and acknowledge the sender's QoS 1 message once you have accepted it:

Because the handler is a single narrow interface, cross-cutting policy composes as decorators that wrap another handler:

The packet each method works with:

Received Returned
Connect — clientId, cleanStart, keepAlive, username, password, will, v5 authMethod/authData, userProperties() Connack::accept() / Connack::refuse($reason)
Subscribe — filters() of Filter { topic, qos } Suback — grant($qos) / deny() per filter
Unsubscribe — filters() Unsuback — success() / fail() per filter
Publish — topic, payload, qos, dup, retain, packetId, userProperties() delivered, not replied
Auth — method, data, userProperties() Auth::success() / Auth::challenge($method, $data)
Puback — packetId resolve with $connection->acknowledge($packetId)

Connections

The Connection handed to every method is the per-client handle. It carries transport state (protocol, cleanStart, keepAlive), the isolation key subscriptions match under (prefix), and an opaque identity the library never reads. You publish through it:

For QoS 1 it tracks in-flight deliveries, so a PUBACK resolves back to the topic and durable sequence it acknowledges (track / resume / acknowledge), advancing a cursor only across a contiguous run of acks — the foundation for offline replay on reconnect.

Adapters and transports

An adapter composes one or more transports into a single process. The Swoole adapter ships Tcp, Tls, and WebSocket transports; UDP-style browsers over WebSocket and native clients over TCP feed the same handler.

A WebSocket message may carry several or partial MQTT packets, so the adapter reassembles whole packets before dispatch and pushes binary frames on send. Keep-alive reaping is intrinsic to MQTT and runs inside the adapter: every inbound packet re-arms a connection's deadline, and a client silent past keepAlive × 1.5 is closed, surfacing as onDisconnect(null, ...).

Telemetry

Pass a utopia-php/telemetry adapter to record broker metrics — packets received by type, connections opened and active, and subscriptions granted or denied. It defaults to a no-op adapter.

Application-specific metrics (authentication latency, delivery counts, and so on) stay in your handler.

MQTT client

The bundled Client talks to a broker over TCP/TLS (mqtt:// / mqtts://): connect, send, receive / listen, with onOpen / onReceive / onClose / onError.

Tests

The unit tier needs no services. The e2e tier starts the Swoole fixture broker in tests/Fixtures/Swoole on ports 18830 (TCP) and 18831 (WebSocket) and runs against it.

Copyright and license

The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php


All versions of mqtt with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
utopia-php/telemetry Version ^0.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package utopia-php/mqtt contains the following files

Loading the files please wait ...