定制 mhamed/laravel-slack-errors-watch 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mhamed/laravel-slack-errors-watch

最新稳定版本:v1.0.0

Composer 安装命令:

composer require mhamed/laravel-slack-errors-watch

包简介

Automatic Slack error reporting for Laravel applications

README 文档

README

Automatic Slack error reporting for Laravel applications. Get instant Slack notifications for every unhandled exception — zero manual setup required.

Installation

composer require mhamed/laravel-slack-errors-watch

Laravel will auto-discover the package. No need to register any service provider manually.

Configuration

1. Create a Slack Webhook URL

  1. Go to https://api.slack.com/apps
  2. Click Create New AppFrom scratch
  3. Give it a name (e.g. "Exception Bot") and select your workspace
  4. In the left sidebar, click Incoming Webhooks
  5. Toggle Activate Incoming Webhooks to On
  6. Click Add New Webhook to Workspace
  7. Select the channel where you want error reports posted and click Allow
  8. Copy the Webhook URL (it looks like https://hooks.slack.com/services/T.../B.../xxxx)

2. Add the Webhook URL to .env

LOG_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T.../B.../xxxx

That's it. The package will automatically report all unhandled exceptions to your Slack channel.

Optional Configuration

Publish the config file to customize behavior:

php artisan vendor:publish --tag=slack-errors-watch-config

This creates config/slack-errors-watch.php with the following options:

Option Default Description
enable_production true Send reports in production
enable_local false Send reports in local environment
auto_report_exceptions true Auto-register in exception handler
ignore [] Exception classes to skip (see below)
log_channel 'slack' Logging channel name
slack_channel_config (see below) Default Slack channel config

Ignoring Exceptions

Add exception classes to the ignore array to prevent them from being reported to Slack. It uses instanceof, so ignoring a parent class also ignores all its subclasses.

'ignore' => [
    \Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class,
    \Illuminate\Auth\AuthenticationException::class,
    \Illuminate\Database\Eloquent\ModelNotFoundException::class,
    \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException::class,
],

Default Slack Channel Config

If your app doesn't already define a slack logging channel, the package creates one automatically using slack_channel_config:

'slack_channel_config' => [
    'driver'   => 'slack',
    'url'      => env('LOG_SLACK_WEBHOOK_URL'),
    'username' => 'Exception Bot',
    'emoji'    => ':boom:',
    'level'    => 'error',
],

Usage

Automatic (default)

With auto_report_exceptions enabled, every unhandled exception is reported to Slack automatically. No code changes needed.

Manual

use Mhamed\SlackErrorsWatch\Facades\SlackErrorsWatch;

// Report an exception
SlackErrorsWatch::logException($exception);

// Send an info message
SlackErrorsWatch::slackLogInfo('Deployment completed successfully');

License

MIT

统计信息

  • 总下载量: 1.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固