定制 denherrring/laravel-mqtt-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

denherrring/laravel-mqtt-client

最新稳定版本:1.0.4

Composer 安装命令:

composer require denherrring/laravel-mqtt-client

包简介

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

README 文档

README

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

Based on bluerhinos/phpMQTT

Installation

composer require denherrring/laravel-mqtt-client

Features

  • Name and Password Authentication
  • Certificate Protection for end to end encryption
  • Enable Debug mode to make it easier for debugging
  • Use LWT Messages and Retrain / QOS Flags

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 >= 5.5.

This step is only required if you are using laravel version <5.5

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

'providers' => [

        DenHerrRing\MqttClient\MqttClientServiceProvider::class,
];

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

'aliases' => [

       'MqttClient' => DenHerrRing\MqttClient\Facades\MqttClient::class,
];

Configuration

Publish the configuration file

php artisan vendor:publish --provider="DenHerrRing\MqttClient\MqttClientServiceProvider"

Config/mqttclient.php

    'host'     => env('mqtt_host','127.0.0.1'),
    'clientId' => env('mqtt_clientId', null),
    '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 DenHerrRing\MqttClient\MqttClientClass\MqttClient;

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

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

        return false;
}

Publishing topic using Facade

use MqttClient;

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

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

        return false;
}

Tested on php 7.3 and laravel 5.7 and also laravel 5.8

Subscription Part is in development

统计信息

  • 总下载量: 7.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固