itsdamien / laravel-api-controller
Simplified API controller, inspired by Jeffrey Way. Compatible with Laravel 5+ and Lumen 5+.
Installs: 49 605
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.6.4
Requires (Dev)
- phpunit/phpunit: ~5.7
- satooshi/php-coveralls: ^1.0
README
A simple api controller helper trait, compatible with Lumen 5+ and Laravel 5+. The goal of this project is to make creating API projects simple. Inspired by Jeffrey Way (https://www.laracasts.com)
Installation
composer require itsdamien/laravel-api-controller
Basic Setup/Usage
use ItsDamien\Api\ApiController; class MyController extends Controller { use ApiController; public function index() { return $this->respond(['status' => 'hello world']); } }
Api Helper functions
Please browse through the source to see a full list.
//200 response $this->respond(); //201 response $this->respondCreated(); //500 error $this->respondServerError(); //422 error $this->respondUnprocessable(); //General error $this->respondWithError('message here');
License
Laravel Api Controller is open-sourced software licensed under the MIT license