Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added a main Debug class to ease integration

  • Loading branch information...
commit 2b305c21d88038b3809432a69682b0865366bca4 1 parent 2ff0927
Fabien Potencier fabpot authored
39 src/Symfony/Component/Debug/Debug.php
View
@@ -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();
+ }
+ }
+}
15 src/Symfony/Component/Debug/README.md
View
@@ -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
---------
3  src/Symfony/Component/Debug/composer.json
View
@@ -18,6 +18,9 @@
"require": {
"php": ">=5.3.3"
},
+ "suggest": {
+ "symfony/class-loader": "2.2.*"
+ }
"autoload": {
"psr-0": { "Symfony\\Component\\Debug\\": "" }
},
1  src/Symfony/Component/HttpKernel/Kernel.php
View
@@ -57,7 +57,6 @@
protected $name;
protected $startTime;
protected $classes;
- protected $errorReportingLevel;
const VERSION = '2.3.0-DEV';
const VERSION_ID = '20300';
Please sign in to comment.
Something went wrong with that request. Please try again.