This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/ErrorHandler
Fabien Potencier 5d15ce4e65 Merge branch '5.1'
* 5.1:
  stop using deprecated PHPUnit APIs
2020-08-17 12:01:44 +02:00
..
Error [ErrorHandler] fix setting $trace to null in FatalError 2020-05-28 12:39:14 +02:00
ErrorEnhancer [ErrorHandler] Remove Symfony ClassLoader support in an error enhancer 2019-11-08 09:41:40 +01:00
ErrorRenderer [ErrorHandler] Allow override of the default non-debug template 2020-07-07 10:32:58 +02:00
Exception Merge branch '4.4' into 5.0 2020-05-24 10:40:42 +02:00
Resources Merge branch '5.0' 2020-05-04 16:13:31 +02:00
Tests Merge branch '4.4' into 5.1 2020-08-17 12:01:29 +02:00
.gitattributes add missing gitattributes for phpunit-bridge 2020-03-27 17:54:36 +01:00
.gitignore Add a new ErrorHandler component (mirror of the Debug component) 2019-07-18 09:54:35 +02:00
BufferingLogger.php [ErrorHandler] merge and remove the ErrorRenderer component 2019-11-10 18:54:30 +01:00
CHANGELOG.md [ErrorHandler] Allow override of the default non-debug template 2020-07-07 10:32:58 +02:00
composer.json Merge branch '4.4' into 5.0 2020-05-24 10:40:42 +02:00
Debug.php [ErrorHandler] silence warning when zend.assertions=-1 2020-02-13 19:41:25 +01:00
DebugClassLoader.php Merge branch '4.4' into 5.1 2020-08-17 09:03:44 +02:00
ErrorHandler.php Merge branch '5.0' into 5.1 2020-06-30 19:42:22 +02:00
LICENSE Update year in license files 2020-01-01 15:47:03 +01:00
phpunit.xml.dist [Debug][ErrorHandler] cleanup phpunit.xml.dist files 2020-05-01 18:55:10 +02:00
README.md [ErrorHandler] Allow override of the default non-debug template 2020-07-07 10:32:58 +02:00
ThrowableUtils.php [ErrorHandler] Forward \Throwable 2019-09-10 14:09:52 +02:00

ErrorHandler Component

The ErrorHandler component provides tools to manage errors and ease debugging PHP code.

Getting Started

$ composer require symfony/error-handler
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\ErrorHandler\ErrorHandler;
use Symfony\Component\ErrorHandler\DebugClassLoader;

Debug::enable();

// or enable only one feature
//ErrorHandler::register();
//DebugClassLoader::enable();

// If you want a custom generic template when debug is not enabled
// HtmlErrorRenderer::setTemplate('/path/to/custom/error.html.php');

$data = ErrorHandler::call(static function () use ($filename, $datetimeFormat) {
    // if any code executed inside this anonymous function fails, a PHP exception
    // will be thrown, even if the code uses the '@' PHP silence operator
    $data = json_decode(file_get_contents($filename), true);
    $data['read_at'] = date($datetimeFormat);
    file_put_contents($filename, json_encode($data));

    return $data;
});

Resources