Download the PHP package jccoca/laravel-api-exceptions without Composer
On this page you can find all versions of the php package jccoca/laravel-api-exceptions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jccoca/laravel-api-exceptions
More information about jccoca/laravel-api-exceptions
Files in jccoca/laravel-api-exceptions
Package laravel-api-exceptions
Short Description A clean and highly customizable REST API Exception Handler for Laravel.
License MIT
Informations about the package laravel-api-exceptions
Laravel API Exceptions
🇧🇷 Para a versão em Português, clique aqui
A lightweight and elegant package to standardize and customize HTTP error and exception responses in Laravel 11, 12, and 13+ REST APIs.
✨ Features
- ⚡ Auto-Format Errors: Catch common API errors (401, 403, 404, 405, 422, 500) and return a consistent JSON payload structure.
- ⚙️ Highly Customizable: Easily change both the error title (
error) and the explanation (message) for any exception using a simple config file. - 🛠️ Force JSON Middleware: Automatically forces all
/apiprefixed routes to returnapplication/jsontransparently. - 🐛 Smart Debugging: Shows file, line, and a clean, simplified stack trace when
APP_DEBUG=true. - 🛡️ Production-Safe: Automatically hides database details and PHP error messages when the application is in production mode.
🚀 Installation
You can install the package via Composer:
🛠️ Configuration
1. Bind the Handler in Laravel
Open your Laravel application's bootstrap/app.php file and call the handler inside the withExceptions block:
2. Publish Configuration (Optional)
If you want to translate or change the default error titles and messages, publish the config file using the Artisan command:
This will create a config/api-exceptions.php file in your project.
📝 Default Output Formats (Examples)
Validation Error (422 Unprocessable Content)
Too Many Requests Error (429 Rate Limit)
Integration / External API Error (502 Bad Gateway - Debug Enabled)
Internal Server Error (500 with Debug Enabled)