PHPackages                             matheus-souza/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. matheus-souza/laravel-mqtt

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

matheus-souza/laravel-mqtt
==========================

A simple Laravel 5 Library to connect/publish to MQTT broker

00PHP

Since Jan 2Pushed 6y ago1 watchersCompare

[ Source](https://github.com/matheus-souza/mqtt-laravel-legacy)[ Packagist](https://packagist.org/packages/matheus-souza/laravel-mqtt)[ RSS](/packages/matheus-souza-laravel-mqtt/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel MQTT Package
====================

[](#laravel-mqtt-package)

A simple Laravel 5 Library to connect/publish to MQTT broker

Based on [bluerhinos/phpMQTT](https://github.com/bluerhinos/phpMQTT)

Installation
------------

[](#installation)

```
composer require salmanzafar/laravel-mqtt

```

Features
--------

[](#features)

- Name and Password Authentication
- Certificate Protection for end to end encryption
- Enable Debug mode to make it easier for debugging

Enable the package (Optional)
-----------------------------

[](#enable-the-package-optional)

This package implements Laravel auto-discovery feature. After you install it the package provider and facade are added automatically for laravel &gt;= 5.5.

**This step is only required if you are using laravel version &lt;5.5**

To declare the provider and/or alias explicitly, then add the service provider to your config/app.php:

```
'providers' => [

        Salman\Mqtt\MqttServiceProvider::class,
];

```

And then add the alias to your config/app.php:

```
'aliases' => [

       'Mqtt' => \Salman\Mqtt\Facades\Mqtt::class,
];

```

Configuration
-------------

[](#configuration)

Publish the configuration file

```
php artisan vendor:publish --provider="Salman\Mqtt\MqttServiceProvider"

```

Config/mqtt.php
---------------

[](#configmqttphp)

```
    'host'     => env('mqtt_host','127.0.0.1'),
    'password' => env('mqtt_password',''),
    'username' => env('mqtt_username',''),
    'certfile' => env('mqtt_cert_file',''),
    'port'     => env('mqtt_port','1883'),
    'debug'    => env('mqtt_debug',false) //Optional Parameter to enable debugging set it to True

```

#### Publishing topic

[](#publishing-topic)

```
use Salman\Mqtt\MqttClass\Mqtt;

public function SendMsgViaMqtt($topic, $message)
{
        $mqtt = new Mqtt();
        $output = $mqtt->ConnectAndPublish($topic, $message);

        if ($output === true)
        {
            return true;
        }

        return false;
}

```

#### Publishing topic using Facade

[](#publishing-topic-using-facade)

```
use Mqtt;

public function SendMsgViaMqtt($topic, $message)
{
        $output = Mqtt::ConnectAndPublish($topic, $message);

        if ($output === true)
        {
            return true;
        }

        return false;
}

```

#### Subscribing topic

[](#subscribing-topic)

```
use Salman\Mqtt\MqttClass\Mqtt;

public function SubscribetoTopic($topic)
    {
        $mqtt = new Mqtt();
        $mqtt->ConnectAndSubscribe($topic, function($topic, $msg){
            echo "Msg Received: \n";
            echo "Topic: {$topic}\n\n";
            echo "\t$msg\n\n";
        });

    }

```

#### Subscribing topic using Facade

[](#subscribing-topic-using-facade)

```
use Mqtt;

public function SubscribetoTopic($topic)
    {
       Mqtt::ConnectAndSubscribe($topic, function($topic, $msg){
            echo "Msg Received: \n";
            echo "Topic: {$topic}\n\n";
            echo "\t$msg\n\n";
        });

    }

```

### Tested on php 7.3 and laravel 5.7 and also laravel 5.8

[](#tested-on-php-73-and-laravel-57-and-also-laravel-58)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/14989876?v=4)[Matheus Henrique de Souza](/maintainers/matheus-souza)[@matheus-souza](https://github.com/matheus-souza)

---

Top Contributors

[![matheus-souza](https://avatars.githubusercontent.com/u/14989876?v=4)](https://github.com/matheus-souza "matheus-souza (1 commits)")

### Embed Badge

![Health badge](/badges/matheus-souza-laravel-mqtt/health.svg)

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M7.0k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M92](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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