定制 stboris/filament-outbox 二次开发

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

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

stboris/filament-outbox

Composer 安装命令:

composer require stboris/filament-outbox

包简介

Configurable notification channels (Discord, Slack, generic webhook) for Laravel, with a Filament v5 admin panel on top.

README 文档

README

Configurable notification channels for Laravel — Discord, Slack, and generic signed webhooks — built on Laravel's native notification system. No new APIs to learn: write a normal Notification class, return a message object, done.

Need an admin UI? Filament Outbox Pro adds a Filament v5 panel on top: endpoint management, send history with retry, test-send buttons, and model-event triggers.

Requirements

  • PHP 8.3+
  • Laravel 13

Installation

composer require stboris/filament-outbox

Optionally publish the config:

php artisan vendor:publish --tag="filament-outbox-config"

Usage

Discord

use Stboris\FilamentOutbox\Messages\DiscordMessage;
use Stboris\FilamentOutbox\Messages\DiscordEmbed;

class TradeOpened extends Notification
{
    public function via(object $notifiable): array
    {
        return ['discord'];
    }

    public function toDiscord(object $notifiable): DiscordMessage
    {
        return DiscordMessage::make()
            ->username('Trading Bot')
            ->embed(fn (DiscordEmbed $embed) => $embed
                ->title('LONG opened — BTCUSDT')
                ->color('#2A78D6')
                ->fields([
                    'Entry price' => '$100.00',
                    'Invested' => '$500.00',
                ])
                ->timestamp());
    }
}

The webhook URL is resolved in this order:

  1. ->to($url) on the message
  2. routeNotificationForDiscord() on the notifiable
  3. config('filament-outbox.discord.webhook_url') (env OUTBOX_DISCORD_WEBHOOK_URL)

Slack (incoming webhook)

use Stboris\FilamentOutbox\Messages\SlackMessage;

public function via(object $notifiable): array
{
    // The 'slack' alias is only claimed when laravel/slack-notification-channel
    // is not installed; the class name always works.
    return [\Stboris\FilamentOutbox\Channels\SlackChannel::class];
}

public function toSlack(object $notifiable): SlackMessage
{
    return SlackMessage::make('Trade closed — +$42.00')
        ->section('*LONG closed — BTCUSDT*');
}

Generic webhook

use Stboris\FilamentOutbox\Messages\WebhookMessage;

public function via(object $notifiable): array
{
    return ['webhook'];
}

public function toWebhook(object $notifiable): WebhookMessage
{
    return WebhookMessage::make([
        'event' => 'trade.closed',
        'symbol' => 'BTCUSDT',
        'pnl' => 42.0,
    ])->header('X-Source', 'my-app');
}

When a secret is configured (OUTBOX_WEBHOOK_SECRET or ->secret(...) on the message), the raw JSON body is signed with HMAC-SHA256 and the hex digest is sent in the X-Outbox-Signature header, so receivers can verify authenticity:

hash_equals($request->header('X-Outbox-Signature'), hash_hmac('sha256', $request->getContent(), $secret));

Testing an endpoint

Verify any endpoint from the command line before relying on it:

php artisan outbox:test discord --to="https://discord.com/api/webhooks/..."
php artisan outbox:test slack                     # uses the configured default URL
php artisan outbox:test webhook --message="Custom check"

Resilient sending

Transient failures — connection errors, HTTP 429 rate limits, and 5xx responses — are automatically retried with exponential backoff (2 attempts by default, configurable via http.retry in the config). Permanent client errors (4xx) fail immediately with a descriptive CouldNotSendNotification exception.

Filament Outbox Pro

The Pro package adds a Filament v5 admin layer on top of these channels:

  • Endpoint management — named destinations managed in the panel instead of .env files: URL, per-environment scoping, enable toggle, channel defaults (bot username, extra headers, …), webhook signing secrets. Reference them from code with ->endpoint('team-alerts') on any message.
  • Send history — every send attempt recorded with status, HTTP code, and payload preview; failed sends can be retried from the panel, with retries recorded as new, linked rows.
  • Test-send — a button on every endpoint to verify it end to end.
  • Model-event triggers — notify on created/updated/deleted for any model, with {placeholder} message templates and optional queued sending with retry/backoff. No notification class needed.

Pro is a separate, commercial package that plugs into this one — nothing in your notification code changes when you add it.

Testing

composer test

License

MIT.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固