承接 xi/error-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

xi/error-bundle

Composer 安装命令:

composer require xi/error-bundle

包简介

Error handling and assertion bundle for Symfony2

README 文档

README

This is a Symfony2 bundle for error and exception handling and logging. It also includes component/service for formatting user readable exception messages according to environment.

Build Status

Installation

This bundle requires:

  • PHP >=5.3
  • Symfony >=2.1
  • Monolog >= 1.3

Monolog 1.3 or greater and compatible Symfony Monolog bridge is required, since that's the first PSR-3 compatible version.

Add to composer.json:

"xi/error-bundle": "1.*"

See packagist for further versions: https://packagist.org/packages/xi/error-bundle

Exception logging

Include XiErrorBundle in your AppKernel.php, and you get automatic exception logging. Logs are created in %kernel.logs_dir%/exception.%kernel.environment%.log.

<?php
...
    public function registerBundles()
    {
        $bundles = array(
        ...
            new Xi\Bundle\ErrorBundle\XiErrorBundle()
        ...
        );
    }
...

Why use separate exception logging?

Default Symfony2 logs have lots of other stuff, that does not help much with debugging and log surveying process. This logger also includes stack traces for exceptions.

Does this handle errors->exception conversion?

Since Symfony 2.2, errors are automatically converted to exceptions.

Exception message formatting

During development, every bit of information helps with debugging the code as soon as errors happen. In production it is desirable to hide the actual, possibly very detailed exception message to the public, and show something generic instead.

Exception message formatter component/service takes an exception, and returns the original exception message or a general error message depending on the current environment. By default, the original exception message is intended to be shown to developer in "test" or "dev" environment, and end-user sees some more general error message in other environments.

<?php
    $message = 'Everything went better than expected.';

    try {
        # try something dangerous
    } catch (Exception $e) {
        # use the service...
        $service = $this->get('xi_error.exception_formatter');
        $message = $service->formatMessage($e, 'could not process your form, please try again');

        # ...or the component directly
        #$message = \Xi\Bundle\ErrorBundle\Component\ExceptionFormatter::formatMessage(
        #    $e,
        #    'could not process your form, please try again',
        #    $this->get('kernel')->getEnvironment()
        #);
    }

    return new Response($message);
    ...

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2013-06-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固