A simple Laravel 5 and 6 Library to connect/publish/subscribe to MQTT broker

laravel package

What's new?

  • Addition of Helper functions to make development more easy

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
  • Now you can also set Client_id of your choice and if you don't want just simply don't use or set it to null
  • Set QOS flag directly from config file
  • Set Retain flag directly from config file
  • Addition of Helper functions to make development more easy

Publishing topic using Helper method

public function SendMsgViaMqtt($topic, $message)
{
        $client_id = Auth::user()->id;

        $output = connectToPublish($topic, $message, $client_id);

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

        return "Failed";
}

Subscribing topic using Helper method

public function SubscribetoTopic($topic)
{
   return connectToSubscribe($topic,$client_id);
}

Source Code

https://github.com/salmanzafar949/MQTT-Laravel