acidjazz/metapi

Laravel API helpers

Installs: 367

Dependents: 0

Suggesters: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Language:HTML

v1.4.3 2019-11-17 03:15 UTC

README

logo.png

Own your endpoint

Latest Stable Version Total Downloads

capture.jpg?raw=true

dark theme with laravel-debugbar

Features

  • Endpoint benchmarking
  • Laravel Validation wrapper that reflects requirements
  • Support for JSON and JSONP
  • Interactive tree browsing with search thanks to jsoneditor

Examples

class OrgController extends Controller
{
    /**
    * Display a listing of the resource.
    *
    * @return \Illuminate\Http\Response
    */
    public function index(Request $request)
    {
        $this
          ->option('approved', 'nullable|boolean');
          ->option('type', 'nullable|in:this,that');
          ->verify();
        ...
        $this->render($results);

GET /endpoint?approved=1

{
    "benchmark": 0.011060953140258789,
    "query": {
        "defaults": [],
        "options": {
            "approved": "nullable|boolean",
            "type": "nullable|in:this,that"
        },
        "params": {
            "approved": "1"
        },
        "combined": {
            "approved": "1"
        }
    },
    "data": [
        {

GET /endpoint?callback=bob

bob({
    "benchmark": 0.011017084121704102,
    "query": {
        "defaults": [],
        "options": {
            "approved": "nullable|boolean",
            "type": "nullable|in:this,that"
        },
        "params": [],
        "combined": []
    },
    "data": [
        {

Installation

Install metapi with composer:

composer require acidjazz/metapi

Make your app/Http/Controllers/Controller.php extend this library

class Controller extends \acidjazz\metapi\MetApiController
{