From 64c1f54978340cecd6d01f8d86615743906bda6b Mon Sep 17 00:00:00 2001 From: Stanislav Zhuk Date: Sat, 20 Apr 2024 20:09:40 +0300 Subject: [PATCH] Laravel 11 compatibility (#7) --- .github/workflows/fix-php-code-style-issues.yml | 2 +- .github/workflows/run-tests.yml | 10 +++++----- README.md | 14 +++++++++++--- composer.json | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/fix-php-code-style-issues.yml index 28816d3..2d26850 100644 --- a/.github/workflows/fix-php-code-style-issues.yml +++ b/.github/workflows/fix-php-code-style-issues.yml @@ -19,7 +19,7 @@ jobs: ref: ${{ github.head_ref }} - name: Fix PHP code style issues - uses: aglipanci/laravel-pint-action@2.3.0 + uses: aglipanci/laravel-pint-action@2.4.0 - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v5 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 318f3ec..f68a1d2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,12 +13,12 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.2] - laravel: [10.*] - stability: [prefer-lowest, prefer-stable] + php: [8.3] + laravel: [11.*] + stability: [prefer-stable] include: - - laravel: 10.* - testbench: 8.* + - laravel: 11.* + testbench: ^9.0 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/README.md b/README.md index ff7d090..ad5c4c8 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ LOG_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/ABC LOG_SLACK_CHANNEL= LOG_SLACK_EMOJI=:boom: LOG_SLACK_CACHE_SECONDS=0 -CACHE_DRIVER=file ``` How to get a webhook URL [in the Slack API docs](https://api.slack.com/messaging/webhooks). @@ -52,7 +51,16 @@ To send a message to Slack, simply call `SlackNotifier::send()`. ## Report Exception ```php -// In Laravel 8.x and later +// In Laravel 11.x and later +// bootstrap/app.php +return Application::configure(basePath: dirname(__DIR__)) + ->withExceptions(function (Exceptions $exceptions) { + $exceptions->reportable(function (Throwable $e) { + \Stasadev\SlackNotifier\Facades\SlackNotifier::send($e); + }); + })->create(); + +// In Laravel 8.x, 9.x, 10.x // app/Exceptions/Handler.php public function register(): void { @@ -170,7 +178,7 @@ You can filter it out with the `dont_trace` config option. Sometimes a large group of exceptions is thrown, and you don't want to log each of them because they are the same. -Use `LOG_SLACK_CACHE_SECONDS` (uses Laravel `CACHE_DRIVER` under the hood) to suppress output for X seconds, or pass it to the `cacheSeconds` function. +Use `LOG_SLACK_CACHE_SECONDS` (uses Laravel cache under the hood) to suppress output for X seconds, or pass it to the `cacheSeconds` function. ```php use Stasadev\SlackNotifier\Facades\SlackNotifier; diff --git a/composer.json b/composer.json index d6bca54..f32305b 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": "^7.1.3 || ^8.0", "ext-json": "*", - "laravel/slack-notification-channel": "^1.0 || ^2.0", + "laravel/slack-notification-channel": "^1.0 || ^2.0 || ^3.0", "monolog/monolog": "^1.12 || ^2.0 || ^3.0", "symfony/polyfill-php80": "^1.20" },