sandreu/cake-sentry

CakePHP2 的 Sentry 错误处理器插件

安装量: 38,339

依赖项: 0

建议者: 0

安全: 0

星标: 16

关注者: 1

分支: 16

开放问题: 3

类型:cakephp-plugin

0.2.0 2016-02-15 10:06 UTC

This package is not auto-updated.

Last update: 2024-09-26 20:41:19 UTC


README

Cake-Sentry 是一个在 Sentry - 文档 上挂载的错误处理器

兼容性

这个库仅与 CakePHP >= 2.8 和 < 3.0 兼容。如果您需要支持 CakePHP < 2.8,请使用 cake-sentry 的 0.1.0 版本。

安装

注意:如果您不是通过 composer 安装,您将需要手动下载 Raven 组件并在进行下一步之前安装它。

  1. 使用 composer 将 Sentry 插件安装到您的 CakePHP 项目中
    // composer.json
    
    // …

    "require": {
      // …
      "sandreu/cake-sentry": "*"
    },

    // …
  1. 在您的 bootstrap.php 中加载 cake-sentry 插件
	CakePlugin::load('Sentry');
  1. 在您的 core.php 中配置错误处理器
	App::uses('SentryErrorHandler', 'Sentry.Lib');
	
	Configure::write('Sentry', array(
		'production_only' => false, // true is default value -> no error in sentry when debug
		'avoid_bot_scan_errors' => 'MissingController or MissingPlugin error message', // or false if you want Sentry to log MissingController and MissingPlugin Exceptions
		'User' => array(
			'model' => 'SpecialUser', // 'User' is default value
			'email_field' => 'special_email' // default checks 'email' and 'mail' fields
		),
		'PHP' => array(
			'server'=>'http://your-sentry-DSN-for-PHP'
		),
		'javascript' => array(
			'server'=>'http://your-sentry-DSN-for-javascript'
		)
	));

	Configure::write('Error', array(
		'handler' => 'SentryErrorHandler::handleError',
		'level' => E_ALL & ~E_DEPRECATED,
		'trace' => true
	));

	Configure::write('Exception', array(
		'handler' => 'SentryErrorHandler::handleException',
		'renderer'=>'ExceptionRenderer'
	));
  1. 使用 Sentry 作为日志记录器
	CakeLog::config('default', array('engine' => 'Sentry.SentryLog'));
  1. 在默认布局中包含 ravenjs 和初始化脚本
	<?php
	echo $this->Html->script('jquery');
	echo $this->Html->script('ravenjs-min');
	?>
	<script type="text/javascript">
		$(function () {
			<?php echo $this->element('Sentry.raven-js'); ?>
		});
	</script>