GitHub
php-exceptions-laravel
Laravel wrapper for PHP-Exception's Library, wiring Laravel's error handling and providing a Rendered for these Exceptions
php-exceptions-laravel
Laravel wiring and JSON / web renderers for the hradigital/php-exceptions domain exception tree.
The base library ships platform-agnostic exceptions - AbstractBaseException and the Client/ and Server/ trees, aligned with HTTP 4xx/5xx semantics - and knows nothing about a transport, leaving every application to decide again how a thrown domain exception becomes a response.
This package decides it once. API requests get a uniform JSON body; web requests throwing a 422 land back on the originating form with errors and old input; every other package exception is answered on the web with the HTTP status it declares. An exception that does not extend AbstractBaseException falls through to Laravel's own handler, untouched.
ExceptionRenderer- the JSON strategy dispatcher, resolving an exception to the first strategy that supports it, with an always-matching fallback.WebRenderer- the web strategy dispatcher, resolving an exception to the first strategy that supports it, with an always-matching fallback.ExceptionsServiceProvider- auto-discovered, binding both dispatchers as singletons and registering tworenderable()hooks on Laravel's exception handler.- API detection - one shared rule across both hooks: the
Acceptheader, a JSON body, anapi/*path, or anapi.*route name. - Bundled strategies -
DefaultRendererandInputFailureRendererfor JSON,InputFailureWebRenderer,UnprocessableEntityWebRendererandDefaultWebRendererfor the web. - Custom strategies - resolve the singleton and prepend your own; the last registration wins.
- PHP
- Laravel
- JavaScript
- Exceptions
- Exceptions-and-error-handling
- Exceptions-handling
- Laravel-framework
- Laravel-package
- Makefile
- Shell