Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Api Exceptions

Laravel Api Exceptions Laravel Package

lanin/laravel-api-exceptions

Standardize error responses in Laravel APIs. This package converts exceptions into consistent, configurable JSON payloads (including JSON:API style), so clients always get predictable, well-formed errors instead of HTML stack traces.

View on GitHub
Deep Wiki
Context7

All in one solution for exception for JSON REST APIs on Laravel and Lumen.

Frequently asked questions about Laravel Api Exceptions
How do I install lanin/laravel-api-exceptions in a Laravel project?
Install it with Composer using composer require lanin/laravel-api-exceptions. Laravel package auto-discovery should register the service provider in a standard setup. You can then publish any optional configuration if the package provides it and verify the exception handler integration in a sandbox service before rolling it out.
Does lanin/laravel-api-exceptions support Laravel 11 and Laravel 12?
The package is designed for Laravel and Lumen JSON APIs, but the evaluation specifically flags Laravel 11+ as a compatibility question. Laravel 11 moved exception configuration into bootstrap/app.php, so confirm the package supports that path rather than only the legacy app/Exceptions/Handler.php model. Test it against your exact Laravel and PHP versions before adopting it.
What JSON error format does laravel-api-exceptions return?
The package converts exceptions into consistent, configurable JSON error payloads instead of HTML stack traces. The overview mentions JSON:API style output as an option, but the exact schema should be treated as something to verify in your own environment. Run contract tests for 401, 403, 404, 422, 429, and 500 responses before standardizing on it.
Can I use laravel-api-exceptions for JSON:API compliant errors?
Yes, the package description says it can produce JSON:API style error responses among its configurable JSON payloads. You should still confirm the exact JSON:API fields and media-type behavior match your client expectations. Use a small set of contract tests to lock down the envelope your API promises.
How are Laravel validation errors handled by laravel-api-exceptions?
Validation errors are one of the critical mappings to verify because Laravel normally returns a 422 response with its own error structure. The package is intended to standardize exception responses, but the evaluation does not document the exact 422 payload. Compare the package output against your existing validation contract before switching it on in production.
Can I map custom domain exceptions to HTTP status codes with this package?
The evaluation describes exception-to-status mapping as configurable, and asks whether custom domain exceptions can be mapped without forking. You should confirm the configuration surface for your own exception classes in a trial service. If the package cannot express your domain exceptions, keep a fallback renderer or decorator in your handler.
Does laravel-api-exceptions work with Lumen?
The package overview says it supports Laravel and Lumen JSON REST APIs. Lumen requires manual bootstrap registration rather than Laravel-style auto-discovery, so expect more setup and validation work. The evaluation also notes Lumen is a shrinking target and should be treated as legacy-only for new standards.
Will laravel-api-exceptions expose stack traces or SQL errors in production?
The package goal is to return well-formed JSON errors instead of HTML stack traces, but production safety depends on your debug settings and exception mapping. The evaluation warns that default or misconfigured behavior could expose stack traces, SQL messages, or internal identifiers. Review the mapping and debug configuration, then test 500 responses with debug disabled.
Does laravel-api-exceptions interfere with Sentry, Telescope, or Laravel logging?
The evaluation calls out the need to verify that the package composes with existing logging and reporting integrations rather than suppressing them. A safe trial should confirm exceptions still reach Sentry, Telescope, and any custom reporters while the JSON response is rendered. Keep your existing handler as a fallback during the pilot.
Is lanin/laravel-api-exceptions production-ready and actively maintained?
The evaluation reports low external validation, with 39 stars and 0 dependents, which suggests a likely single-maintainer bus factor. A recent release is positive for activity but does not prove production adoption or long-term support. The MIT license allows an internal fork if maintenance stalls, but you should assess release cadence, test coverage, and responsiveness before a fleet-wide rollout.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core