Skip to content

1.0.0

Choose a tag to compare

@HRADigital HRADigital released this 05 May 16:47
· 21 commits to master since this release

First public release of hradigital/php-exceptions-laravel.

Laravel wiring + JSON renderer for hradigital/php-exceptions. Translates the upstream
AbstractBaseException tree into a uniform JSON response at the HTTP boundary, only for API requests — browser requests still fall through to
Laravel's default error pages.

Highlights

  • 🚀 Auto-discovered service provider — drop the package in, no manual registration needed. Binds ExceptionRenderer as a singleton and hooks
    Laravel's exception handler via renderable().
  • 🎯 API-only gating — the renderer activates only when the request looks like an API call (expectsJson() / wantsJson(), isJson(), path
    api/*, or route name api.*). HTML / Whoops / Blade error pages are untouched for everything else.
  • 🧩 Strategy-based renderers — pluggable ExceptionRendererInterface; add() prepends so later registrations win. Ships with:
    • DefaultRenderer — always-matching fallback, emits {message, code, data?}.
    • InputFailureRenderer — matches RequestFailureInterface, emits {message, code, rules, failed} with field-keyed rules and a flattened
      per-message list.
  • Tested end-to-end — Orchestra Testbench-backed suite covers dispatcher wiring, both bundled renderers, the service provider, and the
    API-vs-non-API gating logic.

Compatibility

PHP Laravel 10 Laravel 11 Laravel 12
8.1
8.2
8.3
8.4

CI runs lint → phpcs → phpstan (level 6) → phpunit across every cell on every push and PR.

Install

composer require hradigital/php-exceptions-laravel                                                           
                                       
License                                                                                                                                            
 
GPL-3.0-or-later, matching the upstream hradigital/php-exceptions package.