承接 tigron/skeleton-error 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

tigron/skeleton-error

最新稳定版本:v0.2.9

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';
}

统计信息

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

GitHub 信息

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

其他信息

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