定制 alby/report 二次开发

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

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

alby/report

最新稳定版本:v0.1.0

Composer 安装命令:

composer require alby/report

包简介

Official Alby error-tracking SDK for PHP. Ships uncaught exceptions, errors, and manual events to your Alby project.

README 文档

README

Packagist Packagist downloads PHP CI License: MIT

Official Alby error-tracking SDK for PHP 8.2+.

Captures uncaught exceptions, errors, and anything you explicitly report, then ships them to your Alby project where an AI agent can auto-open a fix task.

Install

composer require alby/report

Requires PHP 8.2+, ext-curl, ext-json. No other runtime dependencies.

Use

use Alby\Report\Alby;

Alby::init([
    'dsn'         => getenv('ALBY_DSN'),  // https://<key>@alby.sh/ingest/v1/<app-id>
    'release'     => '1.4.2',
    'environment' => 'production',
]);

// Uncaught exceptions and fatal errors are sent automatically.

// Manual report:
try {
    doThing();
} catch (\Throwable $e) {
    Alby::captureException($e);
}

// Non-error events:
Alby::captureMessage('Failed to acquire lease', 'warning');

// Enrich the scope:
Alby::setUser(['id' => 'u_412', 'email' => 'ada@example.com']);
Alby::setTag('region', 'eu-west-3');
Alby::setContext('billing_tenant', ['plan' => 'pro', 'seats' => 12]);
Alby::addBreadcrumb(['type' => 'http', 'message' => 'GET /api/orders/42']);

// Before exit (e.g. in a worker):
Alby::flush(2000);

The SDK buffers events in memory and ships them on flush() or at register_shutdown_function time. Sending is synchronous with a bounded queue of 100 events; long-running workers should call Alby::flush() at the end of each unit of work.

Laravel

The package auto-discovers its service provider, so nothing else is needed on Laravel 5.5+. Publish the config:

php artisan vendor:publish --tag=alby-report-config

Then set your DSN in .env:

ALBY_DSN=https://<key>@alby.sh/ingest/v1/<app-id>
ALBY_RELEASE=1.4.2

Reporting exceptions

Laravel 11+ (bootstrap/app.php):

->withExceptions(function (Exceptions $exceptions) {
    $exceptions->report(fn (\Throwable $e) => \Alby\Report\Alby::captureException($e));
})

Laravel ≤10 (app/Exceptions/Handler.php):

public function register(): void
{
    $this->reportable(fn (\Throwable $e) => \Alby\Report\Alby::captureException($e));
}

Optional breadcrumbs

In config/alby-report.php:

'breadcrumbs' => [
    'queries' => true,   // DB query breadcrumbs
    'routes'  => true,   // Route-matched breadcrumbs
],

Options

Option Type Default Notes
dsn string — (required) From your Alby app settings.
release string '' Build version. Enables release tracking / auto-resolve.
environment string APP_ENV / production production / staging / dev / anything.
sample_rate float 1.0 Fraction of events actually sent, 0..1.
server_name string gethostname() Attached to every event.
auto_register bool true Install set_exception_handler + set_error_handler + register_shutdown_function. Chains to existing handlers.
debug bool false SDK diagnostics to stderr.
transport Transport CurlTransport Injectable transport (tests, alt delivery).
breadcrumbs_max int 100 Ring-buffer cap.

Wire protocol

This SDK speaks the Alby Ingest Protocol v1. If you're writing an SDK for a new runtime, start there.

Links

License

MIT — © Alby.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固