bowens-h/laravel-mqtt
Composer 安装命令:
composer require bowens-h/laravel-mqtt
包简介
A simple Laravel 5 Library to connect/publish to MQTT broker
关键字:
README 文档
README
A simple Laravel 5 Library to connect/publish to MQTT broker
Based on bluerhinos/phpMQTT
Installation
composer require bowens-h/laravel-mqtt
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)
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' => [
Bowens\Mqtt\MqttServiceProvider::class,
];
And then add the alias to your config/app.php:
'aliases' => [
'Mqtt' => \Bowens\Mqtt\Facades\Mqtt::class,
];
Configuration
Publish the configuration file
php artisan vendor:publish --provider="Bowens\Mqtt\MqttServiceProvider"
Config/mqtt.php
'host' => env('mqtt_host','127.0.0.1'),
'password' => env('mqtt_password',''),
'client_id'=> env('mqtt_client_id',''),
'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 Bowens\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 and also laravel 5.8
Subscription Part is in development
bowens-h/laravel-mqtt 适用场景与选型建议
bowens-h/laravel-mqtt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 73 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「laravel5」 「mqtt-laravel」 「mqtt-laravel-publisher」 「mqtt-laravel-subscriber」 「laravel mqtt library」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bowens-h/laravel-mqtt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bowens-h/laravel-mqtt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bowens-h/laravel-mqtt 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple Laravel Library to connect/publish/subscribe to MQTT broker
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A simple Laravel 5 Library / Client to connect/publish to MQTT broker
Laravel helpers for dev
A simple Laravel Library to connect/publish/subscribe to MQTT broker
Send SMS and SMS Notification via Mailjet for Laravel
统计信息
- 总下载量: 73
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-28