devpulse/laravel 问题修复 & 功能扩展

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

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

devpulse/laravel

Composer 安装命令:

composer require devpulse/laravel

包简介

DevPulse Laravel SDK — auto error capture for Laravel apps

README 文档

README

Real-time error tracking for Laravel — self-hosted and free.

Requires a running DevPulse server v1.0+ and PHP 8.1+.

Installation

composer require devpulse/laravel

Publish the config:

php artisan vendor:publish --tag=devpulse-config

Configuration

Add to .env:

DEVPULSE_DSN=https://your-devpulse-host/api/ingest/YOUR_API_KEY
DEVPULSE_ENV=production
DEVPULSE_RELEASE=1.4.2        # or set APP_VERSION — falls back to git SHA

All options

Variable Default Description
DEVPULSE_DSN Ingest URL with API key (required)
DEVPULSE_ENABLED true Master on/off switch
DEVPULSE_ENV APP_ENV Environment name sent with events
DEVPULSE_RELEASE APP_VERSION / git SHA Release/version tag
DEVPULSE_ASYNC true Fire-and-forget HTTP (recommended)
DEVPULSE_TIMEOUT 2 HTTP timeout in seconds
DEVPULSE_SAMPLE_RATE 1.0 0.0–1.0 fraction of events to send
DEVPULSE_SLOW_QUERY_MS 1000 Slow query threshold (ms)
DEVPULSE_SLOW_REQUEST_MS 3000 Slow request threshold (ms)
DEVPULSE_MIN_LOG_LEVEL error Minimum log level to capture
DEVPULSE_USER_CONTEXT true Attach auth user to events

Capture toggles

Variable Default Description
DEVPULSE_CAPTURE_EXCEPTIONS true Unhandled exceptions
DEVPULSE_CAPTURE_LOGS true Log::error() / Log::critical()
DEVPULSE_CAPTURE_SLOW_QUERIES true Slow DB queries
DEVPULSE_CAPTURE_SLOW_REQUESTS true Slow HTTP requests (requires middleware)
DEVPULSE_CAPTURE_QUEUE_FAILURES true Failed queue jobs
DEVPULSE_CAPTURE_COMMANDS true Artisan command failures (non-zero exit)

What's captured automatically

  • Exceptions — All unhandled exceptions (excluding ignored list)
  • Log::error / critical — Laravel log entries at error level or above
  • Slow queries — DB queries exceeding the threshold, plus all queries as breadcrumbs
  • Slow requests — HTTP requests exceeding the threshold (add middleware)
  • Queue failures — Failed jobs with queue, job class, and attempt count
  • Artisan failures — Commands that exit with a non-zero code
  • User context — Authenticated user ID, email, name (auto-detected)
  • Release — Version tag from DEVPULSE_RELEASE, APP_VERSION, or git SHA
  • Breadcrumbs — Last 20 queries and log entries attached to exceptions

Ignored exceptions

The following are never reported by default (add more in config/devpulse.php):

  • ValidationException
  • AuthenticationException
  • AuthorizationException
  • ModelNotFoundException
  • NotFoundHttpException
  • ThrottleRequestsException
  • TokenMismatchException

Slow request middleware

Register in app/Http/Kernel.php (Laravel 10) or bootstrap/app.php (Laravel 11+):

// Laravel 10 — app/Http/Kernel.php
protected $middleware = [
    \DevPulse\Laravel\Http\Middleware\DevPulseContext::class,
];

// Laravel 11 — bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
    $middleware->append(\DevPulse\Laravel\Http\Middleware\DevPulseContext::class);
})

Manual capture

use DevPulse\Laravel\DevPulseFacade as DevPulse;

// Capture an exception manually
try {
    riskyOperation();
} catch (\Throwable $e) {
    DevPulse::capture($e, ['order_id' => $orderId]);
    throw $e;
}

// Capture a message
DevPulse::captureMessage('Payment gateway timeout', 'warning', [
    'gateway'     => 'stripe',
    'amount'      => $amount,
    'customer_id' => $customerId,
]);

Testing

Use DevPulse::fake() to assert events in tests without hitting the server:

use DevPulse\Laravel\DevPulseFacade as DevPulse;

public function test_order_failure_is_tracked(): void
{
    $fake = DevPulse::fake();

    $this->post('/orders', ['invalid' => 'data']);

    $fake->assertCaptured(\App\Exceptions\PaymentFailedException::class);
}

public function test_slow_payment_is_reported(): void
{
    $fake = DevPulse::fake();

    // ... trigger slow payment ...

    $fake->assertCapturedMessage('Slow request');
}

public function test_healthy_request_sends_nothing(): void
{
    $fake = DevPulse::fake();

    $this->get('/health');

    $fake->assertNothingCaptured();
}

License

MIT

devpulse/laravel 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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