定制 tigron/skeleton-error 二次开发

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

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

tigron/skeleton-error

Composer 安装命令:

composer require tigron/skeleton-error

包简介

Skeleton error handling

README 文档

README

Description

This library contains the error handling logic of skeleton.

It will use filp/whoops and sentry/sentry if their presence can be detected and the required configuration exists. If not, it will fall back to its own basic error handler.

The basic error handlers can print debug information, as well as send e-mail to a configured address.

Installation

Installation via composer:

composer require tigron/skeleton-error

Configuration

If you want to enable skeleton-error for your application, you need to call the Handler::enable() method, which will register the error handlers:

\Skeleton\Error\Handler::enable();

Setting the debug flag to true will result in detailed error messages being displayed in the browser, using the basic built-in handler or filp/whoops, depending on what is available:

\Skeleton\Error\Config::$debug = true;

You can provide additional information to the error handler, such as the release version and the environment the error occurred in. This can help with filtering reports. This is currently only supported by the sentry handler:

\Skeleton\Error\Config::$environment = 'development';
\Skeleton\Error\Config::$release = 'project@1.0.0';

By default, the level for error_reporting will be set to E_ALL. You can configure a different level if desired:

\Skeleton\Error\Config::$error_reporting = E_ALL & ~E_STRICT;

E-mail handler

If you would like to receive error reports via e-mail, set the mail_errors_to and mail_errors_from options to the relevant addresses. You will also need to make sure that the system your application is running on can send mail:

\Skeleton\Error\Config::$mail_errors_to = 'colleague@example.com';
\Skeleton\Error\Config::$mail_errors_from = 'errors@example.com';

Sentry handler

If you would like to use Sentry, you need to install sentry/sdk (recommended) or sentry/sentry (deprecated).

Once installed, configure the DSN which it will use:

\Skeleton\Error\Config::$sentry_dsn = 'http://foo:bar@sentry.example.com/1';

Whoops handler

If you would like to use Whoops, you need to install filp/whoops. No further configuration is required.

Events

Error context

sentry_before_send

The sentry_before_send can have two different signatures, depending on the version of Sentry you have installed.

For sentry\sdk (which depends on sentry/sentry version 2 or higher), the event will be called as the beforeSend callback. In the example below, we use $event->getUserContext() for version 2, whereas version 3 should use $event->getUser(). More information is available here

public function sentry_before_send(\Sentry\Event $event) {
    $event->getUserContext()->setUsername('john-doe');
    return $event;
}

For the deprecated sentry\sentry version 1 and below, the event will be called as the send_callback function. More information is available here

public function sentry_before_send(&$data) {
    $data['user']['username'] = 'john-doe';
}

tigron/skeleton-error 适用场景与选型建议

tigron/skeleton-error 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19.27k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 08 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-14