murganikolay/debug-errorhook
Composer 安装命令:
composer require murganikolay/debug-errorhook
包简介
Intercept PHP errors (including fatals) and process them (e.g. send to E-mail). Based on http://en.dklab.ru/lib/Debug_ErrorHook/ by Dmitry Koterov
README 文档
README
Debug_ErrorHook: Intercept PHP errors (including fatals) and process them (e.g. send to E-mail). (C) Dmitry Koterov, http://en.dklab.ru/lib/Debug_ErrorHook/ This library allows to intercept PHP errors (including fatal!) with their context (file name, line number, often - stack trace, environment etc.) and do some work with this information. You may add any number of hooks which will be called in case of errors. The most common usage is to send PHP notices, warnings and even fatal errors to developer's E-mail. Of course this sending is wise: if the same error already happened within N seconds, it will not be resent, so the mailbox is never overloaded, and sendmail program cannot crash the whole system even if your site is very popular. Commony errors and notices are sent to web server's logs and die there. Nobody monitors server logs oftenly. If these errors are sent do developers' emails, developers could react immediately and fix them. It is quite handy, especially just after production deployment, and it works great especially for fatal errors. Usage sample ------------ Execute this in your script's bootstrap code: $errorsToMail = new Debug_ErrorHook_Listener(); $errorsToMail->addNotifier( new Debug_ErrorHook_RemoveDupsWrapper( new Debug_ErrorHook_MailNotifier( "developer.email@example.com", Debug_ErrorHook_TextNotifier::LOG_ALL ), "/tmp/errors", // lock directory 300 // do not resend the same error within 300 seconds ) ); Or using factory: $factory = new \Debug\ErrorHook\ErrorHookFactory(); $errorsToMail = $factory->create(require 'config/errorhook.php'); // Attention! When $errorsToMail is destroyed (e.g. went out of // scope), error hooks are removed. Hooks are active till $errorsToMail's // destructor execution. So you should commonly save $errorsToMail somewhere // in a safe place (e.g. in $GLOBALS or in a class static property) and // be sure it is not destroyed until your script is finished. Be sure to set error_reporting(E_ALL) to catch all notices. To test notice emailing, execute something like: echo $non_existed_var; call_non_existed_function(); You will receve 2 mails at developer.email@example.com mailbox. First: From: developer.email@example.com To: developer.email@example.com Subject: [ERROR] E_NOTICE: Undefined variable: a at script.php on line 10 //example.com/script.php?args E_NOTICE: Undefined variable: a at script.php on line 10 TRACE: <stack trace> SERVER: <content of $_SERVER> COOKIES: <content of $_COOKIE> GET: <content of $_GET> POST: <content of $_POST> SESSION: <content of $_SESSION> Second mail will contain information about your fatal error. (Unfortunately PHP does not allow to get stack trace for fatal errors, but other information will be mailed correctly, including file name, line number and superglobals state.)
murganikolay/debug-errorhook 适用场景与选型建议
murganikolay/debug-errorhook 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 270 次下载、GitHub Stars 达 0, 最近一次更新时间为 2013 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 murganikolay/debug-errorhook 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 murganikolay/debug-errorhook 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 270
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL
- 更新时间: 2013-02-25