4 Commits

Author SHA1 Message Date
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
936ce0549d GHA: Run tests against PHP 8.2 (#37) 2023-02-14 20:50:15 +01:00
c42ec1d6ff Laravel 10.x Compatibility (#35)
* Bump dependencies for Laravel 10

* Update version constraints in composer.json

---------

Co-authored-by: Marvin Mall <marvin-mall@msn.com>
2023-02-14 20:41:59 +01:00
4 changed files with 60 additions and 51 deletions

View File

@ -15,9 +15,9 @@ jobs:
strategy:
matrix:
php-version: ['7.4', '8.0', '8.1']
php-version: ['7.4', '8.0', '8.1', '8.2']
include:
- php-version: '8.1'
- php-version: '8.2'
run-sonarqube-analysis: true
steps:

View File

@ -1,52 +1,52 @@
{
"name": "php-mqtt/laravel-client",
"description": "A wrapper for the php-mqtt/client library for Laravel.",
"type": "library",
"keywords": [
"mqtt",
"client",
"publish",
"subscribe",
"laravel"
],
"homepage": "https://github.com/php-mqtt/laravel-client",
"license": "MIT",
"authors": [
{
"name": "Marvin Mall",
"email": "marvin-mall@msn.com",
"role": "developer"
}
],
"require": {
"php": "^7.4|^8.0",
"illuminate/config": "~7.0|~8.0|~9.0",
"illuminate/support": "~7.0|~8.0|~9.0",
"php-mqtt/client": "^1.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
"psr-4": {
"PhpMqtt\\Client\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"PhpMqtt\\Client\\MqttClientServiceProvider"
],
"aliases": {
"MQTT": "PhpMqtt\\Client\\Facades\\MQTT"
}
}
},
"scripts": {
"fix:cs": "vendor/bin/phpcbf",
"test": [
"@test:cs"
"name": "php-mqtt/laravel-client",
"description": "A wrapper for the php-mqtt/client library for Laravel.",
"type": "library",
"keywords": [
"mqtt",
"client",
"publish",
"subscribe",
"laravel"
],
"test:cs": "vendor/bin/phpcs"
}
"homepage": "https://github.com/php-mqtt/laravel-client",
"license": "MIT",
"authors": [
{
"name": "Marvin Mall",
"email": "marvin-mall@msn.com",
"role": "developer"
}
],
"require": {
"php": "^7.4|^8.0",
"illuminate/config": "^7.0|^8.0|^9.0|^10.0",
"illuminate/support": "^7.0|^8.0|^9.0|^10.0",
"php-mqtt/client": "^1.3.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
"psr-4": {
"PhpMqtt\\Client\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"PhpMqtt\\Client\\MqttClientServiceProvider"
],
"aliases": {
"MQTT": "PhpMqtt\\Client\\Facades\\MQTT"
}
}
},
"scripts": {
"fix:cs": "vendor/bin/phpcbf",
"test": [
"@test:cs"
],
"test:cs": "vendor/bin/phpcs"
}
}

View File

@ -55,6 +55,10 @@ return [
// with the log level as configured.
'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,
// only a MemoryRepository is supported.
'repository' => MemoryRepository::class,

View File

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