PHPackages                             haider-kamran/laravel-mqtt - 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. haider-kamran/laravel-mqtt

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

haider-kamran/laravel-mqtt
==========================

A production-ready Laravel package that integrates MQTT into Laravel applications in a clean, scalable, and event-driven way.

v1.0.0(1mo ago)00MITPHPPHP ^8.1

Since Jun 11Pushed 1mo agoCompare

[ Source](https://github.com/haider-kamran/laravel-mqtt)[ Packagist](https://packagist.org/packages/haider-kamran/laravel-mqtt)[ RSS](/packages/haider-kamran-laravel-mqtt/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

Laravel MQTT Manager
====================

[](#laravel-mqtt-manager)

[![MQTT Dashboard](image.png)](image.png)[![Latest Version on Packagist](https://camo.githubusercontent.com/2c84f42e83c80916dd6fa3dab497239f91d01cfdde9336fd4960bfe52feceb97/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6861696465722d6b616d72616e2f6c61726176656c2d6d7174742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haider-kamran/laravel-mqtt)[![Total Downloads](https://camo.githubusercontent.com/a45f3704d66dda3c21c9e57da4a311a54065eac603ff702509376baa9ea3c1f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6861696465722d6b616d72616e2f6c61726176656c2d6d7174742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haider-kamran/laravel-mqtt)[![License](https://camo.githubusercontent.com/055a5d354cd04eb572d1bc2ae1567646d64dd2237d663df7e0cf0f6729fac3f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6861696465722d6b616d72616e2f6c61726176656c2d6d7174742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haider-kamran/laravel-mqtt)

A production-ready, highly scalable, and developer-friendly Laravel package that integrates MQTT into your applications. It provides a clean, event-driven, "Horizon-like" architecture for managing IoT streams and long-running MQTT daemons safely.

🚀 Features
----------

[](#-features)

- **Clean Facade API**: Effortless publishing and topic routing (`Mqtt::publish`, `Mqtt::topic`).
- **Event &amp; Job Dispatching**: Map incoming MQTT topics directly to Laravel Events or Jobs, pushing heavy processing to your Queues natively.
- **Robust Worker Daemon**: Run `php artisan mqtt:work` under Supervisor with built-in memory protection, Graceful Shutdown (SIGTERM), and a Heartbeat Lock Manager to prevent duplicate processes.
- **Auto Reconnect &amp; Backoff**: Configurable exponential backoff strategies to handle broker disconnections professionally.
- **Topic Wildcards**: Full support for MQTT wildcards (`+` and `#`).
- **Native Broadcasting**: Seamlessly integrates with Laravel's native Broadcasting (`broadcast(new Event)->toOthers()`) using the custom `mqtt` driver!
- **Premium Real-Time Dashboard**: A built-in, Neo-Noir styled live metrics dashboard accessible out-of-the-box.
- **Strictly Typed**: Built on PHP 8.1 Enums for `QosLevel` and Protocols.

📦 Requirements
--------------

[](#-requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 9.0

🛠 Installation
--------------

[](#-installation)

You can install the package via composer:

```
composer require haider-kamran/laravel-mqtt
```

The package will automatically register its service provider. You should publish the configuration file and dashboard assets using:

```
php artisan vendor:publish --tag=mqtt-config
php artisan vendor:publish --tag=mqtt-views
```

⚙️ Configuration
----------------

[](#️-configuration)

After publishing, you can configure your broker credentials and connection settings in `config/mqtt.php` or your `.env` file:

```
MQTT_HOST=127.0.0.1
MQTT_PORT=1883
MQTT_CLIENT_ID=laravel-app
MQTT_USERNAME=
MQTT_PASSWORD=
MQTT_PROTOCOL=3.1.1
MQTT_KEEP_ALIVE=60
MQTT_RECONNECT=true
MQTT_RECONNECT_MAX_DELAY=60
```

📚 Usage
-------

[](#-usage)

### Publishing Messages

[](#publishing-messages)

You can easily publish messages to any MQTT broker using the `Mqtt` facade. Arrays are automatically JSON-encoded.

```
use Haiderkamran\LaravelMqtt\Facades\Mqtt;
use Haiderkamran\LaravelMqtt\Enums\QosLevel;

Mqtt::publish('device/1/cmd', ['reboot' => true]);

// With QoS and Retain flag
Mqtt::publish('device/status', 'online', QosLevel::EXACTLY_ONCE, true);
```

### Subscribing &amp; Routing Topics

[](#subscribing--routing-topics)

To listen to inbound topics, register your routes within your `AppServiceProvider` or a custom provider's `boot` method.

You can map topics directly to Laravel **Events** or **Jobs**. If a topic matches, the payload will be automatically dispatched to Laravel's native queue ecosystem!

```
use Haiderkamran\LaravelMqtt\Facades\Mqtt;
use App\Events\TemperatureUpdated;
use App\Jobs\ProcessDeviceData;

public function boot()
{
    // Exact Match -> Dispatches a Laravel Event
    Mqtt::topic('sensor/temp')->event(TemperatureUpdated::class);

    // Wildcard Match -> Dispatches a Laravel Job to the Queue
    Mqtt::topic('device/#')->dispatch(ProcessDeviceData::class);

    // Single-level wildcard support
    Mqtt::topic('room/+/lights')->dispatch(ProcessLightCommand::class);
}
```

### Running the Worker Daemon

[](#running-the-worker-daemon)

To start listening for the routed topics, spin up the built-in worker command:

```
php artisan mqtt:work
```

This acts exactly like a Laravel Queue worker. In production, you should use **Supervisor** to keep this process alive. The worker uses Laravel's `Cache` system as a Mutex Lock to ensure multiple instances of the worker don't accidentally run at the same time and duplicate messages.

If your server crashes hard and the lock gets stuck, you can gracefully purge the state using:

```
php artisan mqtt:clear
```

### Native Laravel Broadcasting

[](#native-laravel-broadcasting)

The package registers a custom `mqtt` broadcast driver. This means you can use Laravel's standard broadcasting mechanics to publish to MQTT topics!

In your `.env`:

```
BROADCAST_DRIVER=mqtt
```

Now, any Laravel Event that implements `ShouldBroadcast` will natively publish its payload directly to your MQTT broker, converting Laravel dot notation channels (`private-user.1`) to MQTT slash notation (`private-user/1`) automatically!

📈 Real-Time Dashboard
---------------------

[](#-real-time-dashboard)

The package comes with a highly optimized, beautifully crafted live dashboard. Once installed, simply navigate to:

👉 `http://your-app.test/mqtt`

You will see real-time, glassmorphic metrics of Messages Received, Published, Connection Drops, and the active status of your Worker Daemon.

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [LICENSE.md](LICENSE.md) for more information.

👨‍💻 Author
----------

[](#‍-author)

Built with ❤️ by [Kamran Haider](https://github.com/haider-kamran).

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3443560?v=4)[Syed Kamran Haider](/maintainers/kamranhaider)[@kamranhaider](https://github.com/kamranhaider)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/haider-kamran-laravel-mqtt/health.svg)

```
[![Health](https://phpackages.com/badges/haider-kamran-laravel-mqtt/health.svg)](https://phpackages.com/packages/haider-kamran-laravel-mqtt)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M250](/packages/laravel-ai)[laravel/sail

Docker files for running a basic Laravel application.

1.9k205.7M1.4k](/packages/laravel-sail)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

728176.2k14](/packages/tallstackui-tallstackui)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77922.3M186](/packages/laravel-mcp)[illuminate/queue

The Illuminate Queue package.

20432.6M1.7k](/packages/illuminate-queue)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)

PHPackages © 2026

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