Download the PHP package stasadev/laravel-slack-notifier without Composer
On this page you can find all versions of the php package stasadev/laravel-slack-notifier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stasadev/laravel-slack-notifier
More information about stasadev/laravel-slack-notifier
Files in stasadev/laravel-slack-notifier
Package laravel-slack-notifier
Short Description Send exceptions and dump variables to Slack
License MIT
Homepage https://github.com/stasadev/laravel-slack-notifier
Informations about the package laravel-slack-notifier
Laravel Slack Notifier
Send exceptions and dump variables to Slack.
Installation
Install the package via composer:
All env variables used by this package (only LOG_SLACK_WEBHOOK_URL
is required):
How to get a webhook URL in the Slack API docs.
To temporarily disable all logging, simply comment out LOG_SLACK_WEBHOOK_URL
or set it to an empty string or null
.
Optionally publish the config file with:
Usage
To send a message to Slack, simply call SlackNotifier::send()
.
Report Exception
Dump Variable
Using multiple webhooks
Use an alternative webhook, by specify extra ones in the config file.
The webhook to be used can be chosen using the to
function.
Using a custom webhooks
The to
function also supports custom webhook URLs.
Sending message to another channel
You can send a message to a channel (use LOG_SLACK_CHANNEL
) other than the default one for the webhook, by passing it to the channel
function.
Slack bot customizing
Use username
(use APP_NAME
) and emoji
(use LOG_SLACK_EMOJI
) to make your messages unique, or override them right before sending.
Formatting
Extend the default Stasadev\SlackNotifier\SlackNotifierFormatter::class
to format the messages however you like. Then simply replace the formatter
key in the configuration file.
Additional context in the message
Include additional context
in a Slack message (use dont_flash
to exclude sensitive info from context
). It will be added as an attachment.
Exception stack trace filtering
Stack traces for exceptions in Laravel usually contain many lines, including framework files. Usually, you are only interested in tracking exception details in the application files.
You can filter it out with the dont_trace
config option.
Caching the same exceptions
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 under the hood) to suppress output for X seconds, or pass it to the cacheSeconds
function.
Testing
Credits
Inspired by spatie/laravel-slack-alerts.
- Stanislav Zhuk
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-slack-notifier with dependencies
ext-json Version *
laravel/slack-notification-channel Version ^1.0 || ^2.0 || ^3.0
monolog/monolog Version ^1.12 || ^2.0 || ^3.0
symfony/polyfill-php80 Version ^1.20