Download the PHP package aliirfaan/laravel-simple-api without Composer
On this page you can find all versions of the php package aliirfaan/laravel-simple-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aliirfaan/laravel-simple-api
More information about aliirfaan/laravel-simple-api
Files in aliirfaan/laravel-simple-api
Package laravel-simple-api
Short Description API helper functions: Response formatting, validation
License MIT
Informations about the package laravel-simple-api
Laravel Simple API
This package offers API response formatting function using Laravel Resources and other API helper functions like API request validation.
API resource format
It is good practice to have a generic response format. This package uses the following format:
Error response format
The error response format used is inspired by paypal api guide
Features
- Get a generic response format for you API
- Response formatting for API errors
- API request validation
- All messages are localized
Requirements
Installation
You can install this package on an existing Laravel project with using composer:
Register the ServiceProvider by editing config/app.php file and adding to providers array:
Note: use the following for Laravel <5.1 versions:
Publish files with:
or by using only php artisan vendor:publish
and select the aliirfaan\LaravelSimpleApi\SimpleApiServiceProvider
from the outputted list.
Usage
Response for common API errors
Example VALIDATION_ERROR responses
Example UNKNOWN_ERROR responses
License
The MIT License (MIT)
Copyright (c) 2020
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.