Download the PHP package curly-deni/laravel-api-concern without Composer
On this page you can find all versions of the php package curly-deni/laravel-api-concern. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download curly-deni/laravel-api-concern
More information about curly-deni/laravel-api-concern
Files in curly-deni/laravel-api-concern
Package laravel-api-concern
Short Description Reusable API responses and exception rendering for Laravel
License MIT
Homepage https://github.com/curly-deni/laravel-api-concern
Informations about the package laravel-api-concern
Laravel API Concern
Reusable JSON response helpers and API exception rendering for Laravel 11, 12, and 13.
Installation
Laravel auto-discovers the service provider. It registers the package's English and Russian translations. To customize them, publish the translation files:
Published translations are placed in lang/vendor/api-concern and override the package defaults.
Responses
Use HasApiResponses in a controller to return the standard response envelopes:
Available helpers are data, created, accepted, noContent, resource, createdResource, acceptedResource, and error. Data responses use a data key and include meta only when provided. Error responses use an error object containing code, message, and optional details.
You can also inject Aesis\ApiConcern\Http\ApiResponseFactory directly.
Exception rendering
Add the renderer to the existing withExceptions callback in bootstrap/app.php. Keep the path check in the application so web exceptions continue through Laravel's normal handling:
For matching requests, the renderer converts validation, authentication, authorization, missing model, throttling, HTTP, and unexpected exceptions to a consistent JSON shape. Throw Aesis\ApiConcern\Exceptions\ApiException for an application-specific error:
Translations
The renderer uses Laravel's api-concern::messages.* translation keys. English and Russian defaults are included. Set the application's locale to choose a language, or publish the files and edit them for application-specific wording.
Testing
License
MIT. See LICENSE.md.