25th/zf2-exception-mailer-module

关于此包最新版本(0.1.3)没有可用的许可信息。

提供简单异常邮件发送功能的Zend Framework 2模块

0.1.3 2018-06-12 07:54 UTC

This package is not auto-updated.

Last update: 2024-09-13 09:05:36 UTC


README

这是一个简单的ZF2模块,用于在生产系统上发生异常时发送邮件。在其最简单配置下,它仅发送异常的堆栈跟踪。但您也可以渲染视图并发送HTML邮件。

安装

此模块的安装使用composer。有关composer文档,请参阅getcomposer.org

php composer.phar require 25th/zf2-exception-mailer-module
# (When asked for a version, type `0.*`)

然后,将ExceptionMailer添加到您的config/application.config.php中。

不使用composer的安装不支持官方,并且需要您手动安装composer.json中列出的所有依赖项。

配置

使用应用程序配置来配置邮件发送器

<?php
return array(
	// Exception Stuff
	'exception_mailer' => array(
		// Mail
		'send' => true,
		'sender' => 'your-sender-address@mail.com',
		'recipients' => array(
			'your-recipient-address@mail.com',
		),
		'subject' => 'My Exception Mailer',
		'exceptionInSubject' => false

		// HTML Templates
		'useTemplate' => false,
		'template' => 'error/index'
	),
);

忽略异常

还可以忽略某些异常。只需让它们实现IgnoreExceptionInterface,它们就会被忽略。

HTML邮件

对于HTML邮件,设置useTemplate为true,并使用模板参数进行模板配置。

如果您想使用不同的模板,例如“error/mail”,您还必须在view_manager => template_map数组中定义它,并指定正确的位置。

<?php
return array(
	...
	'view_manager' => array(
		'template_map'        => array(
			...
			'error/mail'              => __DIR__ . '/../view/error/mail.phtml', // Exception_Mailer
			...
		),
	),
	...
);