added a main Debug class to ease integration
This commit is contained in:
parent
2ff09277bd
commit
2b305c21d8
39
src/Symfony/Component/Debug/Debug.php
Normal file
39
src/Symfony/Component/Debug/Debug.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Debug;
|
||||
|
||||
use Symfony\Component\ClassLoader\DebugClassLoader;
|
||||
|
||||
/**
|
||||
* Registers all the debug tools.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Debug
|
||||
{
|
||||
public static function enable($errorReportingLevel = null)
|
||||
{
|
||||
error_reporting(-1);
|
||||
ini_set('display_errors', 0);
|
||||
|
||||
ErrorHandler::register($errorReportingLevel);
|
||||
if ('cli' !== php_sapi_name()) {
|
||||
ExceptionHandler::register();
|
||||
} elseif (!ini_get('log_errors') || ini_get('error_log')) {
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
if (class_exists('Symfony\Component\ClassLoader\DebugClassLoader')) {
|
||||
DebugClassLoader::enable();
|
||||
}
|
||||
}
|
||||
}
|
@ -3,22 +3,29 @@ Debug Component
|
||||
|
||||
Debug provides tools to make debugging easier.
|
||||
|
||||
Here is classic usage of the main provided tools::
|
||||
Enabling all debug tools is as easy as calling the `enable()` method on the
|
||||
main `Debug` class:
|
||||
|
||||
use Symfony\Component\Debug\Debug;
|
||||
|
||||
Debug::enable();
|
||||
|
||||
You can also use the tools individually:
|
||||
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
use Symfony\Component\Debug\ExceptionHandler;
|
||||
|
||||
error_reporting(-1);
|
||||
|
||||
ErrorHandler::register($this->errorReportingLevel);
|
||||
ErrorHandler::register($errorReportingLevel);
|
||||
if ('cli' !== php_sapi_name()) {
|
||||
ExceptionHandler::register();
|
||||
} elseif (!ini_get('log_errors') || ini_get('error_log')) {
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
// from the ClassLoader component
|
||||
DebugClassLoader::enable();
|
||||
Not that the `Debug::enable()` call also registers the debug class loader from
|
||||
the Symfony ClassLoader component when available.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
@ -18,6 +18,9 @@
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/class-loader": "2.2.*"
|
||||
}
|
||||
"autoload": {
|
||||
"psr-0": { "Symfony\\Component\\Debug\\": "" }
|
||||
},
|
||||
|
@ -57,7 +57,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
protected $name;
|
||||
protected $startTime;
|
||||
protected $classes;
|
||||
protected $errorReportingLevel;
|
||||
|
||||
const VERSION = '2.3.0-DEV';
|
||||
const VERSION_ID = '20300';
|
||||
|
Reference in New Issue
Block a user