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
2020-09-07 20:45:32 +02:00
..
Error [ErrorHandler] fix setting $trace to null in FatalError 2020-05-28 12:39:14 +02:00
ErrorEnhancer [ErrorHandler] Parse "x not found" errors correctly on php 8. 2020-09-07 20:45:32 +02:00
ErrorRenderer Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +02:00
Exception Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +02:00
Resources Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +02:00
Tests [ErrorHandler] Parse "x not found" errors correctly on php 8. 2020-09-07 20:45:32 +02:00
.gitattributes add missing gitattributes for phpunit-bridge 2020-03-27 17:54:36 +01:00
.gitignore
BufferingLogger.php
CHANGELOG.md
composer.json Parse and render anonymous classes correctly on php 8 2020-05-24 10:33:35 +02:00
Debug.php Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +02:00
DebugClassLoader.php Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +02:00
ErrorHandler.php Merge branch '3.4' into 4.4 2020-09-02 18:08:58 +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 [DotEnv][WebLink][Templating][ErrorHandler] Updated README with minimal example 2020-05-26 11:42:42 +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();

$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