概述 快速入门 教程 手册 最佳实践 组件 参考 贡献

发布于 2015-08-27 16:41:41 | 114 次阅读 | 评论: 0 | 来源: 网络整理

The Debug component provides tools to ease debugging PHP code.

2.3 新版功能: The Debug component was introduced in Symfony 2.3. Previously, the classes were located in the HttpKernel component.

Installation

You can install the component in many different ways:

Usage

The Debug component provides several tools to help you debug PHP code. Enabling them all is as easy as it can get:

use SymfonyComponentDebugDebug;

Debug::enable();

The enable() method registers an error handler, an exception handler and a special class loader.

Read the following sections for more information about the different available tools.

警告

You should never enable the debug tools in a production environment as they might disclose sensitive information to the user.

Enabling the Error Handler

The ErrorHandler class catches PHP errors and converts them to exceptions (of class ErrorException or FatalErrorException for PHP fatal errors):

use SymfonyComponentDebugErrorHandler;

ErrorHandler::register();

Enabling the Exception Handler

The ExceptionHandler class catches uncaught PHP exceptions and converts them to a nice PHP response. It is useful in debug mode to replace the default PHP/XDebug output with something prettier and more useful:

use SymfonyComponentDebugExceptionHandler;

ExceptionHandler::register();

注解

If the HttpFoundation component is available, the handler uses a Symfony Response object; if not, it falls back to a regular PHP response.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务