Download the PHP package nbdev/bersiv-api-response without Composer
On this page you can find all versions of the php package nbdev/bersiv-api-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nbdev/bersiv-api-response
More information about nbdev/bersiv-api-response
Files in nbdev/bersiv-api-response
Package bersiv-api-response
Short Description A Laravel package for standardized JSON API response structures.
License MIT
Homepage https://github.com/navidbakhtiary/bersiv-api-response
Informations about the package bersiv-api-response
Bersiv API Response
Bersiv API Response is a lightweight Laravel package for returning consistent JSON API responses.
It provides a semantic facade for common API response scenarios, including authentication, validation, data retrieval, process handling, external API failures, rate limits, AI answers, and system errors.
Instead of repeating response structures and messages in every controller, you can return a clear purpose-based response:
Name
Bersiv means response or answer in Kurdish.
The package name reflects its purpose: providing clear and consistent API responses for Laravel applications.
Purpose
The package is designed to make API responses:
- consistent across endpoints
- easier to read in controllers
- easier to document for frontend developers
- easier to translate and customize
- predictable for API clients
Response Structure
Success Response
Success responses use success: true and place payloads under data.
Failure Response
Failure responses use success: false and place payloads under errors.
Empty payloads default to empty arrays instead of null.
Empty Payload Behavior
Empty payloads do not always mean failure.
List-style methods return 200 OK even when the result is empty:
list()filteredList()searchResults()attributesList()valuesList()attributeRanges()dateRange()
Some methods treat an empty payload as a missing result:
detail()returns404 Not Foundwhen the resource payload is empty.aiAnswer()returns404 Not Foundwhen no answer is available.
Features
- Consistent success and failure JSON structures
- Facade-based semantic response methods
- Dedicated response classes for common HTTP scenarios
- Action-based response generators
- Authentication response helpers
- Data response helpers
- Validation response helpers
- Process response helpers
- AI response helper
- Rate limit response helper
- External API failure response helpers
- System error response helper
- Array and
JsonResourcepayload support - Namespaced translation support
- Publishable translation files
- PHPUnit and Orchestra Testbench test coverage
- Laravel Pint code style checks
- Larastan / PHPStan static analysis
Requirements
- PHP 8.2 or higher
- Laravel application compatible with the package version
- Composer
Installation
Laravel package discovery registers the service provider automatically.
Basic Usage
Example response:
More Examples
Validation Failure
Example response:
Empty List Response
Example response:
Detail Not Found Response
Example response:
Available Facade Groups
| Group | Purpose |
|---|---|
| AI | Return AI-generated answers or missing-answer failures. |
| Authentication | Return login, logout, token, and unauthenticated responses. |
| Data | Return detail, list, search, filter, range, and values responses. |
| External API | Return responses for rejected or unavailable third-party APIs. |
| Process | Return responses for accepted, finished, or rejected processes. |
| Rate Limit | Return too many requests responses. |
| System | Return internal server error responses. |
| Validation | Return invalid inputs, invalid attributes, and captcha failures. |
Translations
The package uses namespaced translation keys.
Publish translations with:
The files will be copied to:
Documentation
- Installation
- Response Types
- Facade API Reference
- Usage Examples
- Authentication Responses
- Translations
- PHPDoc Guide
- Testing
- Publishing Checklist
Code Quality
Run the test suite:
Check code style without changing files:
Fix code style automatically:
Run static analysis:
License
MIT