Download the PHP package ultraembeddedlab/php-iot without Composer

On this page you can find all versions of the php package ultraembeddedlab/php-iot. 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 php-iot

PHP IoT MQTT Client

CI Latest Stable Version License PHP Version PHPStan

Modern, production-grade MQTT 3.1.1 & 5.0 client for PHP 8.4+

Features

Requirements

No other extensions are needed: all I/O goes through PHP's stream functions.

Installation

Install via Composer:

Upgrading from ultraembeddedlab/php-iot 1.x? The package was renamed in 2.0 — the PHP namespace is unchanged, so no use statement moves. See UPGRADE.md.

Quick Start

Simple Publish (Fire and Forget)

The easiest way to publish a message:

Publish with TLS and Authentication

Using MQTT 5.0

Subscribe to Topics

For more complex use cases, use the full client:

Long-Running Connection

Use the Mqtt::connect() method for sessions that need to publish multiple messages:

Configuration Options

Client Options

Option Type Default Description
host string required MQTT broker hostname
port int 1883 Broker port. Not derived from TLS — pass 8883 yourself. (Easy\Mqtt::publish() auto-detects; Options does not.)
version MqttVersion V3_1_1 MQTT protocol version
clientId string '' Client identifier. Empty means the broker assigns one, which MQTT 3.1.1 allows only with cleanSession: true. Easy\Mqtt generates one for you.
keepAlive int 60 Keep alive interval in seconds (0–65535). A broker that sends Server Keep Alive in CONNACK overrides this.
pingResponseTimeout float 10.0 How long to wait for a PINGRESP before treating the connection as dead and closing it
cleanSession bool true Start with clean session
username string null Authentication username
password string null Authentication password
will ?WillOptions null Last Will and Testament
autoReconnect bool false Reconnect with exponential backoff — see withAutoReconnect()
offlineQueueSize int 0 Publishes buffered while disconnected, drained on reconnect (0 = off)
rateLimiter ?RateLimiter null Token-bucket throttle for outbound publishes
sessionStore ?SessionStoreInterface null Persist subscriptions across restarts (use with cleanSession: false)
topicAliasMaximum int 0 MQTT 5 topic aliases to request (0 = disabled)
receiveMaximum int 65535 MQTT 5 flow-control window
ackTimeout float 5.0 Timeout (seconds) waiting for QoS 1/2 ACK before resend
maxResendAttempts int 3 Max resend attempts for unacknowledged QoS 1/2 messages
maximumPacketSize int 16 MiB Largest accepted inbound packet; also sent as MQTT 5 property 0x27
inboundQueueSize int 1000 Bound on the awaitMessage()/messages() queue (0 = unlimited)

Publish Options

Option Type Default Description
qos QoS AtMostOnce Quality of Service level
retain bool false Retain message on broker
properties array null MQTT 5.0 properties

TLS Configuration

Simple TLS (server verification only):

withHost('other-broker') resets the port to 1883. When changing host on an existing Options, pass both: withHost('other-broker', 8883).

Mutual TLS with client certificate (AWS IoT, Azure IoT Hub):

MQTT over port 443 with ALPN (when 8883 is blocked):

Self-signed certificates (development):

TlsOptions Method Description
withCaFile(?string) CA certificate file for server verification
withCaPath(?string) Directory of CA certificates
withClientCertificate(?string, ?string, ?string) Client cert, key, and optional passphrase
withAlpn(?string) ALPN protocol (e.g., 'mqtt' for port 443)
withVerifyPeer(bool) Verify server certificate (default: true)
withVerifyPeerName(bool) Verify server hostname (default: true)
withAllowSelfSigned(bool) Allow self-signed certs (default: false)
withPeerName(?string) Override peer name for SNI
withSni(bool) Enable/disable SNI (default: true)
withCryptoMethod(int) Override negotiated TLS versions (bitmask of STREAM_CRYPTO_METHOD_*_CLIENT)

TLS 1.2 and 1.3 only, by default. PHP's own STREAM_CRYPTO_METHOD_TLS_CLIENT still enables TLS 1.0 and 1.1, which RFC 8996 marks MUST NOT and PCI-DSS prohibits. This client refuses them unless you widen the policy explicitly:

Legacy array syntax is still supported for backward compatibility: $options->withTls(['ssl' => ['verify_peer' => true]])

MQTT 5.0 Features

Topic Aliases

Topic aliases replace a repeated topic string with a two-byte integer. They are managed automatically — request a budget on Options, then publish normally:

The broker's topic_alias_maximum in CONNACK overrides your request; if it advertises 0, aliasing is disabled and publishes fall back to full topic strings.

Do not set the topic_alias property by hand on PublishOptions. Aliases are connection-scoped and negotiated — a hand-set value is either overwritten by the client or rejected by the broker with reason code 0x94 (Topic Alias Invalid).

Message Expiry

Set expiration time for messages:

User Properties

Attach custom metadata to messages:

Error Handling

Every error this library raises extends ScienceStories\Mqtt\Exception\MqttException, which extends RuntimeException — so a single catch covers the whole surface.

Exception Raised when
AuthenticationError The broker refused the credentials (CONNACK 4/5 on 3.1.1, 0x86/0x87 on MQTT 5)
ServerError The broker is unavailable, busy, or shutting down
QuotaExceeded A broker rate or quota limit was hit
ProtocolError A malformed packet, an oversized packet, or an invalid local configuration
Timeout No ACK or data arrived within the deadline
TransportError Socket or TLS failure — connection refused, closed by peer, handshake failed

connect() throws rather than returning a failed result, so a refused connection cannot be mistaken for a live one:

A long-running loop should survive transient failures rather than dying on the first one:

With withAutoReconnect() enabled, loopOnce() re-establishes the connection and re-subscribes on its own; it returns false while disconnected rather than throwing.

Known Limitations

Stated up front rather than discovered in production:

See CHANGELOG.md for what changed and what is planned.

Documentation

Feature guides in docs/:

Examples

Check the examples/ directory for complete working examples:

Testing

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

License

PHP IoT MQTT Client is open-sourced software licensed under the MIT license.

Credits

Developed by Bogdan Gewald.

UltraEmbeddedLab is the publishing organisation for this package; copyright is held by Bogdan Gewald, as stated in LICENSE.md. Contributions are accepted under the Developer Certificate of Origin — inbound licence equals outbound licence, MIT. There is no copyright assignment and no CLA.

The PHP namespace is ScienceStories\Mqtt\ for historical reasons: the package was originally published as science-stories/php-iot. It is unchanged for backwards compatibility and is scheduled to be renamed in 3.0 with class_alias() shims — see ROADMAP.md.


All versions of php-iot with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-sockets Version *
psr/log Version ^3.0.2
psr/event-dispatcher Version ^1.0
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 ultraembeddedlab/php-iot contains the following files

Loading the files please wait ...