A collection of helpers for returning a response from your API more expressively.
Simply require the package via composer into your Laravel API.
composer require mbarlow/laravel-response-helpers
No extra setup is required. The helper file is autoloaded via the "autoload" attributes of the composer.json
file.
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return ok($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return created($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return accepted($content, $headers);
/**
* @param array $headers
*/
return noContent($headers);
/**
* @param string $newUrl
* @param array $headers
*/
return movedPermanently($newUrl, $headers);
/**
* @param string $url
* @param array $headers
*/
return found($url, $headers);
/**
* @param string $newUrl
* @param array $headers
*/
return seeOther($newUrl, $headers);
/**
* @param string $tempUrl
* @param array $headers
*/
return temporaryRedirect($tempUrl, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return badRequest($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return unauthorized($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return paymentRequired($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return forbidden($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return notFound($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return methodNotAllowed($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return notAcceptable($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return gone($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return payloadTooLarge($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return unprocessableEntity($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return upgradeRequired($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return tooManyRequests($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return internalServerError($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return notImplemented($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return badGateway($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return serviceUnavailable($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return gatewayTimeout($content, $headers);
/**
* @param \Illuminate\View\View|string|array|null $content
* @param array $headers
*/
return insufficientStorage($content, $headers);
If you wish to run the tests, clone out the repository
git clone [email protected]:mikebarlow/laravel-response-helpers.git
Change to the root of the repository and run composer install with the dev dependencies
cd laravel-response-helpers
composer install
A script is defined in the composer.json
to run both the code sniffer and the unit tests
composer run test
Or run them individually as required
./vendor/bin/phpunit
./vendor/bin/phpcs --standard=PSR2 src
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.