Nicolas Grekas 69f92a208e Merge branch '5.4' into 6.2
* 5.4:
  [Runtime][ErrorHandler] Don't mess with ini_set('assert.warning')
2023-07-16 18:55:01 +02:00
2022-08-25 17:27:04 +02:00
2023-04-11 18:03:19 +02:00
2022-11-02 10:08:04 +01:00
2023-05-05 13:55:01 +02:00
2023-07-16 18:55:01 +02:00
2023-07-16 18:55:01 +02:00
2022-11-02 10:08:04 +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

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