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
Nicolas Grekas d96c7a0f40 Merge branch '5.1'
* 5.1:
  [Debug] fix test
  consistently use same types for strict comparisons
  [PhpUnitBridge] Skip internal classes in CoverageListenerTrait
  [VarExporter] unserialize() might throw an Exception on php 8.
  [SecurityHttp] Don't call createMock() with multiple interfaces.
  [ErrorHandler] Parse "x not found" errors correctly on php 8.
  Prevent parsing invalid octal digits as octal numbers
  remove unnecessary check for  existing request
  [DI] fix ContainerBuilder on PHP8
  [Console] Make sure $maxAttempts is an int or null.
  [VarDumper] Fix caster for invalid SplFileInfo objects on php 8.
  [Intl] Skip test cases that produce a TypeError on php 8.
  [PhpUnitBridge] Adjust output parsing for PHPUnit 9.3.
  [PhpUnitBridge] CoverageListenerTrait update for PHPUnit 8.5/9.x
  add bosnian (bs) translation
  [Debug] Parse "x not found" errors correctly on php 8.
2020-09-08 16:20:09 +02:00
..
Error [ErrorHandler] fix setting $trace to null in FatalError 2020-05-28 12:39:14 +02:00
ErrorEnhancer Merge branch '4.4' into 5.1 2020-09-08 16:19:54 +02:00
ErrorRenderer Merge branch '5.1' 2020-09-02 18:27:44 +02:00
Exception Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +02:00
Resources Merge branch '4.4' into 5.1 2020-09-02 18:23:27 +02:00
Tests Merge branch '4.4' into 5.1 2020-09-08 16:19:54 +02:00
.gitattributes add missing gitattributes for phpunit-bridge 2020-03-27 17:54:36 +01:00
.gitignore
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 Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +02:00
DebugClassLoader.php Merge branch '4.4' into 5.1 2020-09-02 18:23:27 +02:00
ErrorHandler.php Merge branch '4.4' into 5.1 2020-09-02 18:23:27 +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 Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +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