Download the PHP package phpdot/error-handler without Composer

On this page you can find all versions of the php package phpdot/error-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 error-handler

phpdot/error-handler

A modern error handler for PHP: an HTML debug page in development, clean pages in production, RFC 9457 (application/problem+json) responses for JSON clients, and a PSR-15 middleware for framework pipelines. Renderers, solution providers, and context providers are all pluggable, so the same handler adapts from a one-line global setup to a fully wired request pipeline.

Table of Contents

Requirements

Requirement Constraint
PHP >= 8.5
phpdot/contracts ^0.5
psr/http-factory ^1.0
psr/http-message ^2.0
psr/http-server-middleware ^1.0

The package depends on PSR interfaces and the phpdot observability contracts — bring any PSR-7/PSR-17 implementation (for example phpdot/http) and a tracer. Handled exceptions are logged through TracerInterface at the status-mapped level and mark the active span error; there is no PSR-3 surface.

Installation

Usage

Global handler

One line registers set_exception_handler, set_error_handler, and a shutdown handler. Uncaught exceptions render a debug page, PHP warnings and notices become exceptions, and fatal errors are caught on shutdown:

Switch to production for clean pages that expose no internals:

PSR-15 middleware

Wrap the whole application pipeline. The middleware catches any Throwable, renders it via the ExceptionHandler, and returns a PSR-7 response with the correct status code and a Content-Type of application/problem+json or text/html depending on the request:

The exception handler directly

ExceptionHandler is the core. Call handle() to turn a throwable into a rendered string, choosing the renderer from the environment and the request's Accept header:

Status codes are derived from the exception: a getStatusCode() method is honoured, and InvalidArgumentException, DomainException, and the rest map to sensible 4xx/5xx codes.

Solution providers

A solution provider suggests a fix for a known error. Solutions appear on the debug page and in the JSON solutions array. A provider that throws is caught silently — collection never crashes the handler:

Context providers

A context provider adds a named tab of data to the debug page. Like solution providers, a throwing provider is caught silently:

Environment variables collected for the debug page are filtered: any key matching a sensitive name (password, secret, token, key, and similar) is masked. Extend the list with setSensitiveKeys().

Architecture

A throwable enters through the global handler or the PSR-15 middleware. ExceptionHandler assembles an ErrorContext — parsed stack trace, filtered environment, provider tabs, and suggested solutions — then hands it to the renderer chosen for the environment and request.

Renderers implement RendererInterface, so a custom renderer is a drop-in replacement. The two HTML renderers load a plain PHP template from templates/; point their constructor at a different path to fully restyle the page.

Testing

The package is standalone-testable:

License

MIT.

This repository is a read-only mirror, generated by CI from phpdot/monorepo. Pull requests and issues belong in the monorepo.


All versions of error-handler with dependencies

PHP Build Version
Package Version
Requires php Version >=8.5
phpdot/contracts Version ^0.6
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/http-server-middleware 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 phpdot/error-handler contains the following files

Loading the files please wait ...