error-explorer/php-sdk 问题修复 & 功能扩展

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

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

error-explorer/php-sdk

Composer 安装命令:

composer require error-explorer/php-sdk

包简介

Error Explorer SDK for PHP - Automatic error tracking with zero configuration

README 文档

README

Automatic error tracking for PHP applications with zero configuration.

Installation

composer require error-explorer/php-sdk

Quick Start

<?php

use ErrorExplorer\ErrorExplorer;

// Initialize with your project token - that's it!
ErrorExplorer::init([
    'token' => 'your_project_token',
]);

// All errors are now captured automatically

What's Captured Automatically

Type How
Exceptions set_exception_handler
Errors set_error_handler (warnings, notices become breadcrumbs)
Fatal Errors register_shutdown_function
Request Context URL, IP, headers, user-agent
Server Context PHP version, OS, memory usage

Optional Enrichment

You can optionally enrich error reports with additional context:

Add Breadcrumbs

Track the user journey leading to an error:

ErrorExplorer::addBreadcrumb([
    'type' => 'user-action',
    'message' => 'User clicked checkout',
    'data' => ['cart_total' => 149.99]
]);

Set User Context

Identify the affected user:

ErrorExplorer::setUser([
    'id' => 'user_123',
    'email' => 'john@example.com',
    'name' => 'John Doe',
    'plan' => 'pro'
]);

Add Tags

Filter errors in the dashboard:

ErrorExplorer::setTags([
    'feature' => 'checkout',
    'version' => 'v2.1.0'
]);

Add Extra Data

Include additional context:

ErrorExplorer::setExtra([
    'order_id' => 'order_789',
    'items_count' => 3
]);

Manual Capture

Capture exceptions or messages manually:

try {
    // risky operation
} catch (Exception $e) {
    ErrorExplorer::captureException($e, [
        'tags' => ['critical' => 'true'],
        'extra' => ['retry_count' => 3]
    ]);
}

// Or capture a message
ErrorExplorer::captureMessage('Payment processing started', 'info');

Configuration Options

ErrorExplorer::init([
    // Required
    'token' => 'your_project_token',

    // Or use DSN format
    // 'dsn' => 'https://token@api.error-explorer.com/api/v1/webhook',

    // Environment (auto-detected from APP_ENV if not set)
    'environment' => 'production',

    // Release version
    'release' => 'v1.2.3',

    // Capture options (all true by default)
    'capture' => [
        'exceptions' => true,
        'errors' => true,
        'fatal_errors' => true,
    ],

    // Breadcrumb options
    'breadcrumbs' => [
        'max_breadcrumbs' => 50,
    ],

    // Transport options
    'transport' => [
        'async' => true,      // Send after request completes
        'timeout' => 3,       // HTTP timeout in seconds
        'retry' => 2,         // Number of retries
    ],

    // Additional fields to scrub (passwords, tokens already included)
    'scrub_fields' => [
        'custom_secret',
        'api_token',
    ],
]);

Async Sending

By default, errors are sent asynchronously after the response is sent to the user (using fastcgi_finish_request for PHP-FPM or register_shutdown_function). This ensures no impact on response time.

To disable async mode:

ErrorExplorer::init([
    'token' => 'xxx',
    'transport' => ['async' => false],
]);

Long-Running Processes

For workers or daemons, flush events manually:

// In your worker loop
while ($job = getNextJob()) {
    try {
        processJob($job);
    } catch (Exception $e) {
        ErrorExplorer::captureException($e);
        ErrorExplorer::flush(); // Send immediately
    }
}

// At the end
ErrorExplorer::close();

Framework Integration

For framework-specific features (automatic user detection, route info, etc.), use the dedicated packages:

  • Symfony: composer require error-explorer/symfony
  • Laravel: composer require error-explorer/laravel

Requirements

  • PHP 8.1+
  • ext-curl
  • ext-json

License

MIT

error-explorer/php-sdk 适用场景与选型建议

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

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

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

围绕 error-explorer/php-sdk 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-03