Download the PHP package anil/exception-response without Composer

On this page you can find all versions of the php package anil/exception-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package exception-response

Laravel Exception Response

tests static analysis code style coverage

Drop-in JSON exception responses for Laravel 11, 12, and 13 APIs built for the slim application skeleton (no app/Exceptions/Handler.php).


Requirements

Installation

The service provider is auto-discovered.

Usage

Register the renderers inside bootstrap/app.php:

Any request matching api/* or sending Accept: application/json will get a uniform JSON payload:

Web routes still render the standard Laravel error pages.

Response shape

Field Always present Notes
message yes Localized; uses the exception's own message when set, otherwise the translated default
error_code when include_error_code (default true) Stable string like unauthenticated, validation_failed
errors only on ValidationException Field-level validation errors
exception when include_exception_class is true FQCN of the thrown exception
file, line, trace when app.debug and include_trace_in_debug are both true trace is truncated to trace_depth frames

Handled exceptions

Exception Status error_code
ValidationException 422 validation_failed (with errors)
AuthenticationException 401 unauthenticated
AuthorizationException 403 unauthorized
ModelNotFoundException 404 model_not_found
NotFoundHttpException 404 not_found
MethodNotAllowedHttpException 405 method_not_allowed
ThrottleRequestsException 429 too_many_requests
TokenMismatchException 419 csrf_token_mismatch
PostTooLargeException 413 payload_too_large
QueryException 500 query_error
BadMethodCallException 500 bad_method
InvalidArgumentException 400 invalid_argument
BindingResolutionException 500 binding_resolution
Any HttpExceptionInterface exception's status mapped from status when known

Configuration

Publish the config:

config/exception-response.php:

Translations

Default messages live under lang/{locale}/messages.php. English and Spanish ship out of the box. Switch locale anywhere in your app (App::setLocale('es')) and responses follow.

Publish the lang files to override or add languages:

The translation keys (also used as error_code values):

When the thrown exception has a custom message (e.g. abort(404, 'No such record.') or throw new AuthenticationException('Token expired.')), that message wins. Translations are used only when the exception carries the framework's default message or no message at all.

Events

Every JSON response dispatches AnilKumarThakur\ExceptionResponse\Events\ExceptionRendered:

Useful for Sentry / Bugsnag tagging, request-id correlation, or per-tenant alerting.

Extending

Register your own renderer alongside this one. Add it inside withExceptions() after JsonExceptions::register() first-registered wins for matching exception types, so put the more specific callback first:

Development

Architecture

Versioning, security, contributions

Changelog

See CHANGELOG.md.

License

MIT see LICENSE.md.


All versions of exception-response with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package anil/exception-response contains the following files

Loading the files please wait ...