A PHP class for formatting error payloads in applications. This package provides a simple and consistent way to convert error information into a structured array format, making it easier to log, display, or broadcast errors throughout your application.
- Consistent Error Formatting: Provides a custom format for error payloads.
- Laravel Integration: Utilizes
Illuminate\Http\Requestfor request data and accepts anyThrowableinstance for flexible error handling. - PSR-4 Autoloading: Easily integrates into your projects via Composer.
- Robust Error Handling: Supports the latest PHP error handling best practices by using the
Throwableinterface.
- PHP 8.0 or later
- Laravel (if integrating into a Laravel project)
You can install the package via Composer. Add the following line to your project's composer.json file:
composer require pensoft/awt-error-formatterInclude in your PHP class/file
use Pensoft\ErrorPayloadFormatter\ErrorPayloadFormatter;Formatting error
// Format the error payload
$errorPayload = ErrorPayloadFormatter::format(
Request $request,
Throwable $e,
'serviceName',
'serviceId'
);
//send $errorPayload to third-party library or service