10 Commits

Author SHA1 Message Date
a243473d24 修改示例包地址 2023-07-06 14:33:27 +08:00
d5ded08f5e 更新composer文件 2023-07-06 11:29:10 +08:00
dfa86d9dc8 更新README文件 2023-07-06 11:27:46 +08:00
0100c86442 修改包信息 2023-07-06 11:20:58 +08:00
bbaff88e41 修改包名称 2023-07-06 11:16:41 +08:00
42227c7e56 修改包名 2023-07-06 11:07:38 +08:00
30040e8503 Replace deprecated set-output in GHA 2023-05-15 20:14:23 +02:00
68c11c6b4a Fix phpcs in ConnectionManager 2023-05-15 20:10:38 +02:00
b059586d08 Allow broadcasting to a specific log channel (#40)
* Allow broadcasting to a specific log channel

* Fix  check condition

* Update src/ConnectionManager.php

* Update config/mqtt-client.php

---------

Co-authored-by: Namoshek <Namoshek@users.noreply.github.com>
2023-05-15 20:04:29 +02:00
0669643386 Update minimum php-mqtt/client version (#39)
Versions before 1.3.0 don't have setReconnectAutomatically
2023-04-05 18:41:07 +02:00
5 changed files with 18 additions and 9 deletions

View File

@ -41,7 +41,7 @@ jobs:
- name: Get Composer Cache Directory - name: Get Composer Cache Directory
id: composer-cache id: composer-cache
run: | run: |
echo "::set-output name=dir::$(composer config cache-files-dir)" echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies - name: Cache Composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -1,4 +1,4 @@
# php-mqtt/laravel-client # ykxiao/laravel-mqtt-client
[![Latest Stable Version](https://poser.pugx.org/php-mqtt/laravel-client/v)](https://packagist.org/packages/php-mqtt/laravel-client) [![Latest Stable Version](https://poser.pugx.org/php-mqtt/laravel-client/v)](https://packagist.org/packages/php-mqtt/laravel-client)
[![Total Downloads](https://poser.pugx.org/php-mqtt/laravel-client/downloads)](https://packagist.org/packages/php-mqtt/laravel-client) [![Total Downloads](https://poser.pugx.org/php-mqtt/laravel-client/downloads)](https://packagist.org/packages/php-mqtt/laravel-client)
@ -16,10 +16,10 @@ allows you to connect to an MQTT broker where you can publish messages and subsc
## Installation ## Installation
The package is available on [packagist.org](https://packagist.org/packages/php-mqtt/laravel-client) and can be installed using composer: The package is available on [packagist.org](https://packagist.org/packages/ykxiao/laravel-mqtt-client) and can be installed using composer:
```bash ```bash
composer require php-mqtt/laravel-client composer require ykxiao/laravel-mqtt-client
``` ```
The package will register itself through Laravel auto discovery of packages. The package will register itself through Laravel auto discovery of packages.
@ -139,7 +139,7 @@ This library allows you to use all the features provided by [`php-mqtt/client`](
Simply retrieve an instance of `\PhpMqtt\Client\Contracts\MqttClient` with `MQTT::connection(string $name = null)` and use it directly. Simply retrieve an instance of `\PhpMqtt\Client\Contracts\MqttClient` with `MQTT::connection(string $name = null)` and use it directly.
For an extensive collection of examples which explain how to use the MQTT client (directly), For an extensive collection of examples which explain how to use the MQTT client (directly),
you can visit the [`php-mqtt/client-examples` repository](https://github.com/php-mqtt/client-examples). you can visit the [`php-mqtt/client-examples` repository](https://git.tool.dwoodauto.com/ykxiao/client-examples).
## License ## License

View File

@ -1,6 +1,6 @@
{ {
"name": "php-mqtt/laravel-client", "name": "ykxiao/laravel-mqtt-client",
"description": "A wrapper for the php-mqtt/client library for Laravel.", "description": "A wrapper for the ykxiao/laravel-mqtt-client library for Laravel.",
"type": "library", "type": "library",
"keywords": [ "keywords": [
"mqtt", "mqtt",
@ -9,7 +9,7 @@
"subscribe", "subscribe",
"laravel" "laravel"
], ],
"homepage": "https://github.com/php-mqtt/laravel-client", "homepage": "https://git.tool.dwoodauto.com/ykxiao/laravel-matt-client",
"license": "MIT", "license": "MIT",
"authors": [ "authors": [
{ {
@ -22,7 +22,7 @@
"php": "^7.4|^8.0", "php": "^7.4|^8.0",
"illuminate/config": "^7.0|^8.0|^9.0|^10.0", "illuminate/config": "^7.0|^8.0|^9.0|^10.0",
"illuminate/support": "^7.0|^8.0|^9.0|^10.0", "illuminate/support": "^7.0|^8.0|^9.0|^10.0",
"php-mqtt/client": "^1.0" "php-mqtt/client": "^1.3.0"
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "^3.5" "squizlabs/php_codesniffer": "^3.5"

View File

@ -55,6 +55,10 @@ return [
// with the log level as configured. // with the log level as configured.
'enable_logging' => env('MQTT_ENABLE_LOGGING', true), 'enable_logging' => env('MQTT_ENABLE_LOGGING', true),
// Which logging channel to use for logs produced by the MQTT client.
// If left empty, the default log channel or stack is being used.
'log_channel' => env('MQTT_LOG_CHANNEL', null),
// Defines which repository implementation shall be used. Currently, // Defines which repository implementation shall be used. Currently,
// only a MemoryRepository is supported. // only a MemoryRepository is supported.
'repository' => MemoryRepository::class, 'repository' => MemoryRepository::class,

View File

@ -139,11 +139,16 @@ class ConnectionManager
$cleanSession = (bool) Arr::get($config, 'use_clean_session', true); $cleanSession = (bool) Arr::get($config, 'use_clean_session', true);
$repository = Arr::get($config, 'repository', Repository::class); $repository = Arr::get($config, 'repository', Repository::class);
$loggingEnabled = (bool) Arr::get($config, 'enable_logging', true); $loggingEnabled = (bool) Arr::get($config, 'enable_logging', true);
$logChannel = Arr::get($config, 'log_channel', null);
$settings = $this->buildConnectionSettings(Arr::get($config, 'connection_settings', [])); $settings = $this->buildConnectionSettings(Arr::get($config, 'connection_settings', []));
$repository = $this->application->make($repository); $repository = $this->application->make($repository);
$logger = $loggingEnabled ? $this->application->make('log') : null; $logger = $loggingEnabled ? $this->application->make('log') : null;
if ($logger && $logChannel) {
$logger = $logger->channel($logChannel);
}
$client = new MqttClient($host, $port, $clientId, $protocol, $repository, $logger); $client = new MqttClient($host, $port, $clientId, $protocol, $repository, $logger);
$client->connect($settings, $cleanSession); $client->connect($settings, $cleanSession);