castiron/typo3-plugin-rollbar

TYPO3 的 Rollbar 集成 (https://rollbar.com)

安装: 11

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 11

分支: 0

开放问题: 0

类型:typo3-cms-extension

2.2.1 2018-05-04 23:11 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:41:58 UTC


README

这是 Rollbar 库,包括自动加载和配置约定。

关于 composer 模式的说明

为了让此插件兼容 "Composer 模式" 和传统非 Composer 模式的 TYPO3 安装,我们无法在 composer.json 中自动 "require" Rollbar(抱歉!)这是因为,即使在非 composer 模式下,TYPO3(例如 v6)也会抛出一个错误,表示系统中没有找到 rollbar/rollbar,因为(显然)TYPO3 会读取 composer.json 文件并尝试根据它理解依赖关系,无论你使用哪种模式。

因此:如果你通过 Composer(使用 Composer 模式)包含此插件,你将需要手动包含依赖项 rollbar/rollbar,它将被建议但不作为依赖项自动安装。

关于自动加载(非 Composer 模式)的说明

我们不在此扩展中包含 Rollbar 库。如果你以老式方式(通过扩展管理器或通过 Git 子模块)包含此插件,你将没有 Rollbar 库及其内部依赖项。你必须使用 Composer 来自动加载它们。一种方法是

  1. 将 composer.json 添加到你的项目根目录,将 rollbar/rollbar 添加为依赖项
  2. composer install
  3. 通过从 typo3conf/AdditionalConfiguration.php 文件的顶部使用 require_once 来在项目中包含 composer 的 vendor/autoload.php
  4. 如果你使用部署系统(如 Capistrano)或其他自动化部署方法,你需要在部署中确保添加一个 composer install 步骤。

快速入门

配置可以指定如下

/**
 * Rollbar config
 */
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rollbar'] = array(
    'rollbar_enabled' => true, // You can use this to turn it off/on
    'rollbar_config' => array(
        'access_token' => '[my-server-side-access-token]',
        'environment' => 'my-environment-name', // This is arbitrary and will scope your reporting in Rollbar
    ),
    /**
     * These are defaults
     */
//    'set_exception_handler' => false,
//    'set_error_handler' => false,
//    'report_fatal_errors' => true,
);

/**
 * Initialize Error Handling. Do this after the rollbar config. The error handling must get
 * instantiated early on, which is why we don't use helper methods from ExtensionManagementUtility, etc.
 */
require_once(PATH_site . 'typo3conf/ext/rollbar/Classes/Utility/Initializer.php');
\CIC\Rollbar\Utility\Initializer::initErrorHandling();

将此放入你的 typo3conf/AdditionalConfiguration.php。一般来说,你放在那里的内容会直接传递给 Rollbar::init(),所以你可以使用 Rollbar::init() 支持的所有选项

注意:除非你指定了值来覆盖它,否则 "root" 配置值(用于与你的 SCM 仓库的路径映射)将自动分配给 PATH_site

如果你使用默认的 set_exception_handler=falseset_error_handler=false

  • 你仍然会自动收到任何致命错误
  • 你可以手动捕获/报告异常,如下所示
try {
    // ... do a lil dance
} catch (\Exception $e) {
    /**
    * Send the exception to Rollbar
    */
    \CIC\Rollbar\Utility\RollbarUtility::reportError($e);

    /**
    * Or you could do one of these:
    *
    * \CIC\Rollbar\Utility\RollbarUtility::reportWarning($e);
    * \CIC\Rollbar\Utility\RollbarUtility::reportNotice($e);
    */
}

TYPO3 内容对象渲染器异常

有时 TYPO3 核心库中的 ContentObjectRenderer 会抛出异常,这在生产环境中是非常棒的,因为你的用户在前端会看到类似的东西,

哎呀,出错了!代码:201705082151141a71f8db

不会有其他异常被抛出或记录。😓

为了解决这个问题,你需要在网站上添加一点 typoscript。在你的主 typoscript 模板上的 "包含" 选项卡下添加 Rollbar 内容异常处理 typoscript。

祝你在所有努力中好运。