snakano/cake-sentry

CakePHP2的错误处理器插件

安装: 621

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 16

开放问题: 0

类型:cakephp-plugin

0.2.0 2024-07-01 01:05 UTC

This package is auto-updated.

Last update: 2024-08-31 01:54:40 UTC


README

Cake-Sentry 是一个连接到 Sentry - 文档 的错误处理器插件

安装

注意:如果您不是通过composer安装,您将需要手动下载raven组件并安装,然后再进行下一步。

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

    // …

    "require": {
      // …
      "snakano/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
		'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>