Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kosmosx/response

Response HTTP package for Simfony, Laravel, Lumen and PHP 7 with standard REST API
https://github.com/kosmosx/response

hateoas-response http-foundation json-response laravel laravel-package lumen lumen-package package response-management rest-api restful-api symfony symfony-api symfony-bundle

Last synced: 27 days ago
JSON representation

Response HTTP package for Simfony, Laravel, Lumen and PHP 7 with standard REST API

Awesome Lists containing this project

README

        

# Documentation
![](https://img.shields.io/badge/version-1.0.2-green.svg)
![](https://img.shields.io/badge/Laravel->=7.1-blue.svg)
![](https://img.shields.io/badge/Symfony->=4.2-blue.svg)

### Let's go
**Composer**

composer require kosmosx/response

require __DIR__ . '/vendor/autoload.php';
$response = new Kosmosx\Response\RestResponse();

$handler = Kosmosx\Response\Exceptions\Handler();
$handler->setExceptionHandler();

**use it**

$response = new Kosmosx\Response\RestResponse($content, $status, $headers); //constructor
$response = new Kosmosx\Response\Factory\FactoryResponse::success(); //factory

$response->withData(true); //add to json array with key 'data'

## Example

$response->success()
->withData(['test' => true])
->withData(['test2' => false])
->withMessage('Microservice Lumen work')
->withState();

//response
{
"data": {
"test": true,
"test2": false
},
"messages": "Microservice Lumen work",
"state": "OK"
}

**en**: [documentation](https://github.com/FabrizioCafolla/response-http/wiki/Response-http-documentation)

**it**: [documentazione](https://github.com/FabrizioCafolla/response-http/wiki/Documentazione-response-http)

***

If you find a bug or want to contribute, write to [email protected]