ftxrc / apicontroller by Alphapixels
forked from eventhomes/laravel-apicontroller

Simplified API controller, inspired by Jeffrey Way. Compatible with Laravel 5+ and Lumen 5+. Forked from eventhomes
36
2
2
Package Data
Maintainer Username: Alphapixels
Maintainer Contact: roundedvision@gmail.com (Bill Richards)
Package Create Date: 2016-03-22
Package Last Update: 2016-06-20
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-12-19 03:13:20
Package Statistics
Total Downloads: 36
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laravel 5 / Lumen 5 Api Controller

Fork of EventHomes' APIController trait. Has a few fixes and customizations that make it more useful, like prettyprinting and raw responses.

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]