A simple object for creating api responses.
Install this package through Composer.
Edit your project's composer.json
file to require californiamountainsnake/json-response
:
{
"name": "yourproject/yourproject",
"type": "project",
"require": {
"php": "^7.1",
"californiamountainsnake/json-response": "*"
}
}
and run composer update
run this command in your command line:
composer require californiamountainsnake/json-response
<?php
use CaliforniaMountainSnake\JsonResponse\JsonResponse;
return JsonResponse::error(['error_1', 'error_2', 'error_3'], JsonResponse::HTTP_BAD_REQUEST)->make();