2025-06-13 09:39:48 +02:00
2024-05-17 12:50:43 +02:00
2024-01-23 14:36:40 +01:00
2024-11-05 16:34:40 +01:00
2023-07-04 14:05:11 +02:00
2024-11-05 16:34:40 +01:00
2023-01-24 15:02:46 +01:00
2021-05-26 19:33:56 +02:00
2021-06-29 11:21:24 +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

Description
⚠️ ARCHIVED: Original GitHub repository no longer exists. Preserved as backup on 2026-01-22T16:32:42.612Z
Readme MIT 1.2 MiB
Languages
PHP 92.1%
CSS 4.7%
JavaScript 3.2%