radnan/rdn-exception 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

radnan/rdn-exception

Composer 安装命令:

composer require radnan/rdn-exception

包简介

Zend Framework 2 module to normalize errors and exceptions

README 文档

README

The RdnException ZF2 module normalizes all framework errors to use native PHP Exceptions.

Two exception classes to handle HTTP response are included with the module:

  • RdnException\AccessDeniedException - Throwing this exception will result in a 403 response.
  • RdnException\BadGatewayException - Throwing this exception will result in a 502 response.
  • RdnException\BadRequestException - Throwing this exception will result in a 400 response.
  • RdnException\MethodNotAllowedException - Throwing this exception will result in a 405 response.
  • RdnException\NotFoundException - Throwing this exception will result in a 404 response.
  • RdnException\UnauthorizedException - Throwing this exception will result in a 401 response.
  • RdnException\UnprocessableEntityException - Throwing this exception will result in a 422 response.

All other exceptions will result in a 500 response.

Additionally a third class RdnException\PublicException is included for cases where you'd like to display the exception message to the user. All HTTP exceptions extend from this class.

How to install

  1. Use composer to require the radnan/rdn-exception package:

    $ composer require radnan/rdn-exception:1.*
  2. Activate the module by including it in your application.config.php file:

    <?php
    
    return array(
        'modules' => array(
            'RdnException',
            // ...
        ),
    );

How to use

Most of the configuration is done using the rdn_exception option.

You can customize the messages that are shown to the user if exceptions are not displayed. And finally you can control the templates used for exception type.

Exceptions are sorted by their HTTP status code. The following is an example configuration:

<?php

return array(
	'rdn_exception' => array(
		'messages' => array(
			'e403' => <<<HTML
<p>
	You are not authorized to access this page.
</p>
HTML
			, 'e404' => <<<HTML
<p>
	The page you're trying to reach doesn't exist.
</p>
HTML
			, 'e500' => <<<HTML
<h2>Report Error</h2>
<p>
	Please contact <a href="mailto:email@example.org">email@example.org</a> to report the problem.
</p>
HTML
		),

		'templates' => array(
			'e403' => 'rdn-exception/error/403',
			'e404' => 'rdn-exception/error/404',
			'e500' => 'rdn-exception/error/500',
		),
	),

	'view_manager' => array(
		'display_exceptions' => false,
	),
);

统计信息

  • 总下载量: 38
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-12-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固