eventhomes / laravel-apicontroller
Simplified API controller, inspired by Jeffrey Way. Compatible with Laravel 5+ and Lumen 5+.
Installs: 92 261
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 5
Forks: 2
Open Issues: 0
Requires
- php: ^7.2
- illuminate/http: 6.*|7.*
- illuminate/support: 6.*|7.*
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 eventhomes/laravel-apicontroller
Basic Setup/Usage
... use EventHomes\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');
Add Fractal Helpers
Please use [https://github.com/eventhomes/laravel-fractalhelper]