Skip to content
Laravel API response package.
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
composer.json
composer.lock

README.md

Laravel API Responses

License Latest Stable Version

This is a helper package based on the Laracasts Incremental APIs tutorial series for returning correctly formed json responses for API calls.

Installation

Require this package with composer:

composer require wboyz/laravel-api-responses

After updating composer, add the ServiceProvider to the providers array in config/app.php:

Laravel 5.x:

WBoyz\LaravelApiResponses\WResponseServiceProvider::class,

If you want to use the facade, add this to your facades in app.php:

'WResp' => WBoyz\LaravelApiResponses\Facades\WResponse::class,

Usage

You can return responses using the Facade (when added), using the supported methods:

public function index() {
    return WResp::respondNotFound('Not Found!');
}

You can now return responses using the global helper function wresponse:

public function index() {
    return wresponse()->respondNotFound('Not Found!');
}
You can’t perform that action at this time.