{"id":25345502,"url":"https://github.com/jmrashed/laravel-slack-notifier","last_synced_at":"2025-09-02T11:39:57.139Z","repository":{"id":277512999,"uuid":"932656644","full_name":"jmrashed/laravel-slack-notifier","owner":"jmrashed","description":"A package for sending exceptions and variables to Slack notifications","archived":false,"fork":false,"pushed_at":"2025-02-14T11:20:28.000Z","size":232,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-14T18:39:31.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmrashed.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-14T09:28:42.000Z","updated_at":"2025-02-14T11:20:32.000Z","dependencies_parsed_at":"2025-04-24T18:55:25.183Z","dependency_job_id":"7934b3de-31b9-41d1-8cd6-63fb7e1ab32a","html_url":"https://github.com/jmrashed/laravel-slack-notifier","commit_stats":null,"previous_names":["jmrashed/laravel-slack-notifier","mrzstack/laravel-slack-notifier"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jmrashed/laravel-slack-notifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Flaravel-slack-notifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Flaravel-slack-notifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Flaravel-slack-notifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Flaravel-slack-notifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmrashed","download_url":"https://codeload.github.com/jmrashed/laravel-slack-notifier/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Flaravel-slack-notifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273279409,"owners_count":25077314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-14T12:35:28.181Z","updated_at":"2025-09-02T11:39:57.117Z","avatar_url":"https://github.com/jmrashed.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--image  --\u003e\n![Laravel Slack Notifier Package](Notification.png)\n\n# Laravel Slack Notifier Package\n\nA simple package to send notifications to Slack using webhooks, with support for customizations such as multiple webhooks, channels, bot name, emojis, and more.\n\n## Table of Contents\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Usage](#usage)\n  - [Send Message](#send-message)\n  - [Report Exceptions](#report-exceptions)\n  - [Dump Variables](#dump-variables)\n  - [Multiple Webhooks](#multiple-webhooks)\n  - [Send Message to Another Channel](#send-message-to-another-channel)\n  - [Customize Slack Bot](#customize-slack-bot)\n  - [Message Formatting](#message-formatting)\n  - [Additional Context](#additional-context)\n  - [Exception Stack Trace Filtering](#exception-stack-trace-filtering)\n  - [Cache Same Exceptions](#cache-same-exceptions)\n- [Testing](#testing)\n- [License](#license)\n\n## Installation\n\nTo install the package, run the following composer command:\n\n```bash\ncomposer require jmrashed/laravel-slack-notifier\n```\n\n### Configuration\n\nOnce the package is installed, you need to set up the environment variables for the Slack webhook and other configuration options.\n\nAdd the following entries to your `.env` file:\n\n```dotenv\nAPP_NAME=Laravel\nLOG_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/ABC\nLOG_SLACK_CHANNEL=\nLOG_SLACK_EMOJI=:boom:\nLOG_SLACK_CACHE_SECONDS=0\n```\n\n- `LOG_SLACK_WEBHOOK_URL` is **required** and should be set to your Slack webhook URL. [Learn how to create a webhook](https://api.slack.com/messaging/webhooks).\n- The other environment variables are optional. You can set `LOG_SLACK_CHANNEL` to specify a channel or use `LOG_SLACK_EMOJI` to set a custom emoji for the Slack messages.\n\nTo temporarily disable notifications, either comment out or set the `LOG_SLACK_WEBHOOK_URL` to an empty string or `null`.\n\nOptionally, you can publish the config file with the following Artisan command:\n\n```bash\nphp artisan vendor:publish --tag=\"slack-notifier\"\n```\n\n## Usage\n\n### Send Message\n\nTo send a message to Slack, use the following code:\n\n```php\nuse Jmrashed\\SlackNotifier\\Facades\\SlackNotifier;\n\nSlackNotifier::send('Test message');\n```\n\nYou can also send exceptions:\n\n```php\nSlackNotifier::send(new \\RuntimeException('Test exception'));\n```\n\n### Report Exceptions\n\nTo automatically report exceptions to Slack, configure your Laravel exception handler.\n\n#### Laravel 11.x and later\nIn `bootstrap/app.php`:\n\n```php\nreturn Application::configure(basePath: dirname(__DIR__))\n    -\u003ewithExceptions(function (Exceptions $exceptions) {\n        $exceptions-\u003ereportable(function (Throwable $e) {\n            \\Jmrashed\\SlackNotifier\\Facades\\SlackNotifier::send($e);\n        });\n    })-\u003ecreate();\n```\n\n#### Laravel 8.x, 9.x, and 10.x\nIn `app/Exceptions/Handler.php`:\n\n```php\npublic function register(): void\n{\n    $this-\u003ereportable(function (Throwable $e) {\n        \\Jmrashed\\SlackNotifier\\Facades\\SlackNotifier::send($e);\n    });\n}\n```\n\n#### Laravel 7.x\nIn `app/Exceptions/Handler.php`:\n\n```php\npublic function report(Throwable $exception)\n{\n    if ($this-\u003eshouldReport($exception)) {\n        \\Jmrashed\\SlackNotifier\\Facades\\SlackNotifier::send($exception);\n    }\n\n    parent::report($exception);\n}\n```\n\n#### Laravel 5.x, 6.x\nIn `app/Exceptions/Handler.php`:\n\n```php\npublic function report(Exception $exception)\n{\n    if ($this-\u003eshouldReport($exception)) {\n        \\Jmrashed\\SlackNotifier\\Facades\\SlackNotifier::send($exception);\n    }\n\n    parent::report($exception);\n}\n```\n\n### Dump Variables\n\nYou can also send variables (strings, arrays, objects) to Slack:\n\n```php\nuse Jmrashed\\SlackNotifier\\Facades\\SlackNotifier;\n\n$variable = 'message';  // or $variable = ['key' =\u003e 'value'];\nSlackNotifier::send($variable);\n```\n\n### Multiple Webhooks\n\nYou can configure multiple webhook URLs in the `config/slack-notifier.php` file:\n\n```php\n// config/slack-notifier.php\n\n'webhook_urls' =\u003e [\n    'default' =\u003e 'https://hooks.slack.com/services/ABC',\n    'testing' =\u003e 'https://hooks.slack.com/services/DEF',\n],\n```\n\nTo use a specific webhook, specify the webhook name:\n\n```php\nuse Jmrashed\\SlackNotifier\\Facades\\SlackNotifier;\n\nSlackNotifier::to('testing')-\u003esend('Test message');\n```\n\n### Send Message to Another Channel\n\nTo send a message to a different Slack channel, use the `channel` method:\n\n```php\nuse Jmrashed\\SlackNotifier\\Facades\\SlackNotifier;\n\nSlackNotifier::channel('reminders')-\u003esend('Test message');\n```\n\n### Customize Slack Bot\n\nYou can customize the bot’s name and emoji:\n\n```php\nuse Jmrashed\\SlackNotifier\\Facades\\SlackNotifier;\n\nSlackNotifier::username('My Laravel Bot')-\u003eemoji(':tada:')-\u003esend('Test message');\n```\n\n### Message Formatting\n\nIf you need to format the message before sending, extend the default `SlackNotifierFormatter` class:\n\n```php\n// config/slack-notifier.php\n\n'formatter' =\u003e App\\Formatters\\CustomSlackNotifierFormatter::class,\n```\n\n### Additional Context\n\nYou can include additional context in the message. Use the `context` method to pass additional information as an attachment in the message.\n\n### Exception Stack Trace Filtering\n\nFilter out unnecessary stack trace lines (e.g., from framework files) by configuring the `dont_trace` option in the config.\n\n### Cache Same Exceptions\n\nTo avoid logging the same exception multiple times, use the `LOG_SLACK_CACHE_SECONDS` configuration. It defines how long exceptions will be cached before being logged again.\n\nAlternatively, you can specify the cache duration programmatically:\n\n```php\nuse Jmrashed\\SlackNotifier\\Facades\\SlackNotifier;\n\nSlackNotifier::cacheSeconds(60)-\u003esend(new \\RuntimeException('Test exception'));\n```\n\n## Testing\n\nTo run the tests for this package, use the following command:\n\n```bash\ncomposer test\n```\n\n## License\n\nThis package is licensed under the MIT License. See the [License File](LICENSE.md) for more details. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmrashed%2Flaravel-slack-notifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmrashed%2Flaravel-slack-notifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmrashed%2Flaravel-slack-notifier/lists"}