Go to file
Salman Zafar c23c5d1ba2 Readme.md 2019-02-28 17:40:34 +05:00
src Added facade support 2019-02-27 12:28:27 +05:00
.gitignore Working on documentation 2019-02-25 14:30:35 +05:00
Readme.md Readme.md 2019-02-28 17:40:34 +05:00
composer.json updated composer.json file 2019-02-28 17:33:57 +05:00

Readme.md

Laravel MQTT Package

A simple Package that can be used to connect to Mqtt using laravel

Based on bluerhinos/phpMQTT

Installation

composer require salmanzafar/laravel-mqtt

Features

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

Configuration

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

Config/mqtt.php

    '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

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

use Mqtt;

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

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

        return false;
}

Tested on php 7.3 and laravel 5.7

Subscribing part under development

Full documentation Coming Soon