andriichuk/pushbox 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

andriichuk/pushbox

Composer 安装命令:

composer require --dev andriichuk/pushbox

包简介

Laravel developer tool: preview FCM push payloads from notifications in the browser—Mailbook-style registry (add, to, category, variants, locales), optional DB rollback, and gated test sends.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Pushbox is a Laravel package inspired by Mailbook: it lets you preview FCM push payloads for Notification classes in the browser, without wiring a one-off controller in your app.

Requirements: PHP 8.4+, Laravel 11 or 12.

Installation

composer require --dev andriichuk/pushbox

Register the service provider and facade (Laravel 11+ auto-discovers them; otherwise add Andriichuk\Pushbox\PushboxServiceProvider to config/app.php).

Publish configuration (optional):

php artisan vendor:publish --tag="pushbox-config"

Scaffold the registration file:

php artisan pushbox:install

This creates routes/pushbox.php where you register notifications (same idea as Mailbook’s routes/mailbook.php).

Usage

Open /pushbox (or your configured pushbox.path) when the app runs with routes enabled (by default: local only — see Security).

Registering notifications

// routes/pushbox.php
use Andriichuk\Pushbox\Facades\Pushbox;
use App\Notifications\OrderShippedNotification;

Pushbox::add(OrderShippedNotification::class);

Pushbox::add(function (): OrderShippedNotification {
    $order = Order::factory()->create();

    return new OrderShippedNotification($order);
});

Notifiable (to())

Many notifications expect a notifiable user. Mirror Mailbook’s API:

Pushbox::to(User::factory()->make())->add(WelcomeNotification::class);

You can also scope several registrations:

Pushbox::to(User::factory()->make())->group(function () {
    Pushbox::add(WelcomeNotification::class);
    Pushbox::add(TrialEndedNotification::class);
});

Categories & groups

Pushbox::category('Orders')->group(function () {
    Pushbox::add(OrderCreatedNotification::class);
    Pushbox::add(OrderShippedNotification::class);
});

Variants

Pushbox::add(OrderCreatedNotification::class)
    ->variant('1 item', fn () => new OrderCreatedNotification(Order::factory()->withOneProduct()->create()))
    ->variant('2 items', fn () => new OrderCreatedNotification(Order::factory()->withTwoProducts()->create()));

Localization

Add locales to config/pushbox.php (locales array). The UI shows a dropdown; the preview resolver sets app()->setLocale() while resolving payloads.

Database rollback

When pushbox.database_rollback is true, previews run inside a DB transaction that is rolled back after rendering (handy when factories persist models), similar to Mailbook.

FCM (push)

Install the channel package (suggested):

composer require laravel-notification-channels/fcm

Implement toFcm($notifiable) on your notification as documented by that package. Pushbox serializes the returned FcmMessage via toArray() for the UI — no Firebase HTTP request happens during preview.

Test sending (optional)

Dangerous: sends a real notification through your configured FCM driver.

  • PUSHBOX_ALLOW_SEND=true
  • pushbox.send.fcm.token / PUSHBOX_FCM_TOKEN for test sends
  • By default, sends are only reasonable in local; set PUSHBOX_SEND_NON_LOCAL=true (and pushbox.send_allow_non_local) only if you explicitly need staging.

Every send is logged under the pushbox.sent / pushbox.send_failed context.

Security

  • Routes register when pushbox.enabled is true and either pushbox.local_only is false or the environment is local / testing.
  • Optional IP allowlist: PUSHBOX_ALLOWED_IPS (comma-separated).
  • Keep the package in require-dev if you only need previews locally.

Mailbook parity (overview)

Mailbook Pushbox
routes/mailbook.php routes/pushbox.php
Mailbook::add() Pushbox::add()
Mailbook::to() / group() / category() / variant() Same fluent ideas
Preview HTML mail Preview FCM JSON
Optional send Optional FCM send (gated)

Testing

composer test
# or
./vendor/bin/phpunit

License

The MIT License. See LICENSE.md.

andriichuk/pushbox 适用场景与选型建议

andriichuk/pushbox 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「testing」 「notifications」 「laravel」 「preview」 「pushbox」 「FCM」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 andriichuk/pushbox 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 andriichuk/pushbox 我们能提供哪些服务?
定制开发 / 二次开发

基于 andriichuk/pushbox 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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