https://github.com/symfony/error-handler
Provides tools to manage errors and ease debugging PHP code
https://github.com/symfony/error-handler
component php symfony symfony-component
Last synced: about 2 months ago
JSON representation
Provides tools to manage errors and ease debugging PHP code
- Host: GitHub
- URL: https://github.com/symfony/error-handler
- Owner: symfony
- License: mit
- Created: 2019-07-18T08:42:44.000Z (over 6 years ago)
- Default Branch: 7.2
- Last Pushed: 2025-05-02T09:21:48.000Z (8 months ago)
- Last Synced: 2025-05-05T22:54:55.567Z (8 months ago)
- Topics: component, php, symfony, symfony-component
- Language: PHP
- Homepage: https://symfony.com/error-handler
- Size: 775 KB
- Stars: 2,639
- Watchers: 5
- Forks: 19
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
ErrorHandler Component
======================
The ErrorHandler component provides tools to manage errors and ease debugging PHP code.
Getting Started
---------------
```bash
composer require symfony/error-handler
```
```php
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
---------
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)
in the [main Symfony repository](https://github.com/symfony/symfony)