Download the PHP package lighthouse/error-handler without Composer
On this page you can find all versions of the php package lighthouse/error-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download lighthouse/error-handler
More information about lighthouse/error-handler
Files in lighthouse/error-handler
Download lighthouse/error-handler
More information about lighthouse/error-handler
Files in lighthouse/error-handler
Vendor lighthouse
Package error-handler
Short Description Error and Exception Handler for the Lighthouse framework
License MIT
Package error-handler
Short Description Error and Exception Handler for the Lighthouse framework
License MIT
Please rate this library. Is it a good library?
Informations about the package error-handler
Lighthouse Error Handler
Error and Exception Handler for the Lighthouse framework.
Installation
Requirements
- PHP 8.2 or higher
Features
- Debug and production error pages
- HTTP exception classes (404, 401, 403, 405, etc.)
- HTML and JSON error renderers
- PSR-15 error middleware
- Custom renderer support
- Error logging integration
Quick Start
Basic Usage
HTTP Exceptions
Throw HTTP-specific exceptions:
PSR-15 Middleware
Use as middleware in your pipeline:
Error Logging
Add an error logger:
Debug vs Production Mode
Debug mode (development):
- Detailed error page with stack trace
- Exception class name and file location
- Request information
Production mode:
- Clean, user-friendly error page
- Generic error messages for 500 errors
- No sensitive information exposed
JSON Responses
The handler automatically detects Accept: application/json and returns JSON:
In debug mode:
Custom Renderers
Create custom error renderers:
API Reference
ErrorHandler
| Method | Description |
|---|---|
handle(Throwable, ServerRequestInterface) |
Handle exception and return response |
registerRenderer(string $contentType, RendererInterface) |
Register custom renderer |
setDefaultRenderer(RendererInterface) |
Set default renderer |
isDebug() |
Check if debug mode is enabled |
setDebug(bool) |
Set debug mode |
HTTP Exceptions
| Exception | Status Code |
|---|---|
BadRequestException |
400 |
UnauthorizedException |
401 |
ForbiddenException |
403 |
NotFoundException |
404 |
MethodNotAllowedException |
405 |
HttpException |
Custom |
ErrorMiddleware
| Method | Description |
|---|---|
process(ServerRequestInterface, RequestHandlerInterface) |
PSR-15 middleware |
setErrorLogger(callable) |
Set error logging callback |
Testing
License
MIT License. See LICENSE for details.
Part of the Lighthouse Framework
This package is part of the Lighthouse Framework, an educational PHP framework designed to teach how modern frameworks work internally.
All versions of error-handler with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.2
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
The package lighthouse/error-handler contains the following files
Loading the files please wait ...