Download the PHP package meritum/http-exception-handler without Composer

On this page you can find all versions of the php package meritum/http-exception-handler. 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 http-exception-handler

meritum/http-exception-handler

HTTP exception handler that translates exceptions into structured JSON error responses using the meritum/structured-logging pipeline.

Requirements

Installation

Usage

Module registration

Register ExceptionHandlerModule alongside StructuredLoggingModule. StructuredLoggingModule requires a LoggerInterface to already be registered:

ExceptionHandlerModule registers:

How it works

When an exception reaches the HTTP kernel boundary:

  1. ExceptionHandlerInterface::handle() is called with the exception and the current request
  2. The exception is passed through the meritum/structured-logging translate→report pipeline — it is translated to a domain exception and logged
  3. An ErrorEnvelope is built from the domain exception and returned as a JSON response

HTTP exceptions (implementing HttpExceptionInterface) are translated by HttpExceptionTranslationHandler into an HttpDomainException, which carries the request context and sets the appropriate log severity. Any other exception falls through to the structured-logging catch-all translator and produces a generic 500 response.

Response format

All error responses use a consistent JSON envelope:

Custom HTTP exceptions

Extend HttpException or implement HttpExceptionInterface directly to define domain-specific HTTP exceptions:

Throw the exception from within the request pipeline:

HttpExceptionTranslationHandler matches any HttpExceptionInterface, so custom exceptions are handled automatically with no additional registration.

Custom translation handlers

To produce a different domain exception for a specific HTTP exception type, implement TranslationHandler and register it at a higher priority than the default handler (0):

Register and tag it in your module:

Because this handler runs at priority 1, it matches before HttpExceptionTranslationHandler (0) for ValidationHttpException instances. All other HTTP exceptions continue to be handled by the default.

Using ErrorEnvelope directly

ErrorEnvelope is public API. Use it to build consistent error responses anywhere in your application:

Attaching additional errors

Call withErrors() to attach a list of error detail objects to the envelope. The shape of each entry is up to the caller — withErrors() carries any string-keyed map:

This produces:

errors is omitted from the response entirely when withErrors() is not called. withErrors() replaces any previously set errors — pass the full list in a single call.

License

MIT


All versions of http-exception-handler with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
georgeff/kernel Version ^1.6
meritum/http Version ^1.0
meritum/structured-logging Version ^1.0
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 meritum/http-exception-handler contains the following files

Loading the files please wait ...