2017 © Pedro Peláez
 

library larapie

Expose your models through an api in a minute!

image

thomasruiz/larapie

Expose your models through an api in a minute!

  • Wednesday, October 11, 2017
  • by thomasruiz
  • Repository
  • 1 Watchers
  • 6 Stars
  • 26 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

larapie

Expose your models through an api in a minute!, (*1)

So that's still in "beta", but not for long, 'coz it's working pretty well., (*2)

Requirements

  • PHP 5.6
  • Laravel 5.1

Installation

Install from composer:, (*3)

composer require thomasruiz/larapie

After installing, add the service provider to your config/app.php file if you're not on Laravel 5.5:, (*4)

Larapie\LarapieServiceProvider::class,

Add the default larapie.php configuration file, (*5)

php artisan vendor:publish --provider=Larapie\\LarapieServiceProvider

Usage

The configuration file

// config/larapie.php
<?php

return [
  // Group configuration (optional)
  'group' => [
    'as'         => 'api.',
    'domain'     => 'api.domain.com',
    'middleware' => 'api',
  ],

  'resources' => [
    // Generates:
    // GET /users
    // GET /users/{user}
    // POST /users
    // PUT /users/{user}
    // DELETE /users/{user}
    'users' => App\User::class,

    // Relationship
    'users.foos' => App\Foo::class,

    // More complex example
    'foos' => [
      // Mandatory
      'model' => App\Foo::class,

      // All the rest is optional

      'disable_routing' => true, // default to false
      'request' => App\Http\Requests\FooRequest::class, // will run for routes store and update
      'requests' => [
        // Further customization
        'store' => App\Http\Requests\Foo\StoreRequest::class,
        'update' => App\Http\Requests\Foo\UpdateRequest::class,
      ],
      'router_options' => [
        'only' => ['index', 'show'],
        'middleware' => ['auth'],
      ],
    ],

    // WON'T WORK, 'bar' model is unknown
    'bar.foo' => App\Foo::class,
  ],
];

And everything is ready!, (*6)

Checklist

  • [ ] API versioning
  • [ ] JWT bundled in
  • [ ] Pagination, ordering and filters on index route
  • [ ] Use of Laravel Policies
  • [ ] Custom error messages

The Versions

11/10 2017

dev-master

9999999-dev

Expose your models through an api in a minute!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Thomas Ruiz