Error
1 year ago
ErrorEnhancer
1 year ago
ErrorRenderer
1 year ago
Exception
1 year ago
Internal
2 years ago
Resources
1 year ago
BufferingLogger.php
1 year ago
Debug.php
1 year ago
DebugClassLoader.php
1 year ago
ErrorHandler.php
1 year ago
LICENSE
2 years ago
README.md
2 years ago
ThrowableUtils.php
2 years ago
README.md
45 lines
| 1 | ErrorHandler Component |
| 2 | ====================== |
| 3 | |
| 4 | The ErrorHandler component provides tools to manage errors and ease debugging PHP code. |
| 5 | |
| 6 | Getting Started |
| 7 | --------------- |
| 8 | |
| 9 | ``` |
| 10 | $ composer require symfony/error-handler |
| 11 | ``` |
| 12 | |
| 13 | ```php |
| 14 | use Symfony\Component\ErrorHandler\Debug; |
| 15 | use Symfony\Component\ErrorHandler\ErrorHandler; |
| 16 | use Symfony\Component\ErrorHandler\DebugClassLoader; |
| 17 | |
| 18 | Debug::enable(); |
| 19 | |
| 20 | // or enable only one feature |
| 21 | //ErrorHandler::register(); |
| 22 | //DebugClassLoader::enable(); |
| 23 | |
| 24 | // If you want a custom generic template when debug is not enabled |
| 25 | // HtmlErrorRenderer::setTemplate('/path/to/custom/error.html.php'); |
| 26 | |
| 27 | $data = ErrorHandler::call(static function () use ($filename, $datetimeFormat) { |
| 28 | // if any code executed inside this anonymous function fails, a PHP exception |
| 29 | // will be thrown, even if the code uses the '@' PHP silence operator |
| 30 | $data = json_decode(file_get_contents($filename), true); |
| 31 | $data['read_at'] = date($datetimeFormat); |
| 32 | file_put_contents($filename, json_encode($data)); |
| 33 | |
| 34 | return $data; |
| 35 | }); |
| 36 | ``` |
| 37 | |
| 38 | Resources |
| 39 | --------- |
| 40 | |
| 41 | * [](https://symfony.com/doc/current/contributing/index.htmlContributing](https://symfony.com/doc/current/contributing/index.html](https://symfony.com/doc/current/contributing/index.html) |
| 42 | * [](https://github.com/symfony/symfony/issuesReport issues](https://github.com/symfony/symfony/issues](https://github.com/symfony/symfony/issues) and |
| 43 | [](https://github.com/symfony/symfony/pullssend Pull Requests](https://github.com/symfony/symfony/pulls](https://github.com/symfony/symfony/pulls) |
| 44 | in the [](https://github.com/symfony/symfonymain Symfony repository](https://github.com/symfony/symfony](https://github.com/symfony/symfony) |
| 45 |