Download the PHP package hatchyu/laravel-api-exceptions without Composer
On this page you can find all versions of the php package hatchyu/laravel-api-exceptions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hatchyu/laravel-api-exceptions
More information about hatchyu/laravel-api-exceptions
Files in hatchyu/laravel-api-exceptions
Package laravel-api-exceptions
Short Description API-first reusable JSON exception classes for Laravel with proper HTTP status codes
License MIT
Informations about the package laravel-api-exceptions
Laravel API Exceptions
A small library of reusable API exception classes for Laravel apps. Each exception
implements Responsable, so throwing one returns a JSON error response with an
appropriate HTTP status code.
Requirements
- PHP
^8.2 - Laravel
11.x,12.xor13.x
Install
The service provider is auto-discovered by Laravel.
Usage
If you omit a message, a default is generated from the class name, for example
BadRequestException becomes "Bad request.".
Factory Helpers Some domain exceptions expose convenient factory methods for consistent messages:
Note: DocumentUploadException is deprecated in favor of FileUploadException.
Common Exceptions
BadRequestException(400)UnauthorizedException(401)ForbiddenException(403)NotFoundException(404)ConflictException(409)UnprocessableEntityException(422)TooManyRequestsException(429)InternalServerErrorException(500)ServiceUnavailableException(503)
Namespaces
Hatchyu\ApiExceptions\Http(top-level HTTP status exceptions)Hatchyu\ApiExceptions\Auth(authentication/authorization helpers)Hatchyu\ApiExceptions\General(domain-friendly helpers)Hatchyu\ApiExceptions\Model(model operation helpers)Hatchyu\ApiExceptions\Validation(validation helpers)
Custom Exceptions
Create your own by extending Hatchyu\ApiExceptions\Base\ApiBaseException and
overriding customHttpCode().
Localization
This package ships English translations in resources/lang/en. You can override
them in your app by placing files under
resources/lang/{locale}/vendor/api-exceptions.
Publishing Translations To publish the translation files into your application for editing:
All versions of laravel-api-exceptions with dependencies
illuminate/database Version ^11.0 || ^12.0 || ^13.0
illuminate/auth Version ^11.0 || ^12.0 || ^13.0
illuminate/http Version ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^11.0 || ^12.0 || ^13.0