Download the PHP package mojtabarks/api-response without Composer
On this page you can find all versions of the php package mojtabarks/api-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mojtabarks/api-response
More information about mojtabarks/api-response
Files in mojtabarks/api-response
Package api-response
Short Description A lighweight package to create appropriate response
License MIT
Informations about the package api-response
Laravel / lumen response api
a lightweight package for create and pass response for use in laravel || lumen
Prerequisites
laravel or lumen > v5.4
Installation
Usage
you can use Facade or Dependency injection in your project :
Facade Example :
use Mojtabarks\ApiResponse\ApiResponse;
ApiResponse::successResponse() // ->setCode(xxxx) // ->setMessage("blah blah blah blah !") // ->setSuccessStatus(--boolean !!!--) // ->setResponseKey('data') // ->setResponseValue(--array-- => [ // --------------> SET DATA METHOD IS ONLY AVAILABLE FOR SUCCESS RESPONSE 'projectName' => 'my awesome project', . . . ]) ->render();
ApiResponse::failureResponse() // ->setCode(xxxx) // ->setMessage("blah blah blah blah !") // ->setSuccessStatus(--boolean !!!--) // ->setResponseKey('error') // ->setResponseValue(--array-- => [ // --------------> SET ERROR METHOD IS ONLY AVAILABLE FOR ERROR RESPONSE 'error text' => 'looks like something went wrong', . . . ]) ->render();
ApiResponse::customResponse() // ->setCode(xxxx) // ->setMessage("blah blah blah blah !") // ->setSuccessStatus(--boolean !!!--) // ->setResponseKey('additional') // ->setResponseValue(--array-- => [ // --------------> SET ADDITIONAL METHOD IS ONLY AVAILABLE FOR CUSTOM RESPONSE // 'custom message' => 'custom message goes here', // . // . // . // ]) ->render();
Dependency injection Example :
1. first inject your class in constructor
``
2. use your injected classes wherever you want !
`
Authors
- Mojtaba Rakhisi - Initial work - github
License
This project is licensed under the MIT License - see the LICENSE.md file for details