2017 © Pedro Peláez
 

library apify

API generator for laravel 5

image

consoletvs/apify

API generator for laravel 5

  • Monday, October 9, 2017
  • by ErikCampobadal
  • Repository
  • 4 Watchers
  • 26 Stars
  • 45 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 3 Versions
  • 5 % Grown

The README.md

Apify

API generator for Laravel 5

StyleCI StyleCI StyleCI, (*1)

Apify Logo, (*2)

Table Of Contents

Installation

To install apify use composer, (*3)

Download

composer require consoletvs/apify

Add service provider & alias

Add the following service provider to the array in: config/app.php, (*4)

ConsoleTVs\Apify\ApifyServiceProvider::class,

Publish the assets

php artisan vendor:publish

Configuration

To configure the package go to: config/apify.php, (*5)

The default file have a valid example and it's documented, check it out, should look like this:, (*6)

<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Prefix used to access the API
    |--------------------------------------------------------------------------
    */
    'prefix' => 'apify',

    /*
    |--------------------------------------------------------------------------
    | Enables or disabled the whole API endpoints
    |--------------------------------------------------------------------------
    */
    'enabled' => true,

    /*
    |--------------------------------------------------------------------------
    | The tables enabled for the api and it's columns
    |--------------------------------------------------------------------------
    */
    'tables' => [

        // Specify all the tables below

        'users' => [

            // The columns from the table that will be displayed in the JSON

            'id', 'name', 'email', 'created_at', 'updated_at'

        ],

    ],
];

Usage

Visit the endpoint like this:, (*7)

Website URL + /api/ + Prefix + /{table}/{accessor?}/{data?}

table: is the table you want to look at, must be an index of the table array in the configuration., (*8)

accessor: is optional, and it's the colum to filter data., (*9)

data: is the data you're filtering, you can add multiple data separated with a ,, (*10)

Note: Remember that all calls to the API goes first to the api middleware, if you need to modify the api throttle go to: App\Http\Kernel.php and modify the api throttle., (*11)

'api' => [
    'throttle:60,1',
    'bindings',
],

The 60 determines the max calls / minute., (*12)

The 1 determines the minutes to wait if the max calls are exceded., (*13)

Some examples:, (*14)

http://localhost/web/Laralum3/public/api/apify/users (example URL)
{"users":[{"id":1,"name":"\u00c8rik Campobadal","email":"ConsoleTVs@gmail.com","created_at":"2016-09-22 16:13:28","updated_at":"2016-10-02 11:18:25"},{"id":2,"name":"Second User","email":"ConsoleTV2s@gmail.com","created_at":"2016-09-21 16:13:28","updated_at":"2016-09-22 16:20:00"},{"id":3,"name":"Third User","email":"ConsoleTV3s@gmail.com","created_at":"2016-08-22 16:13:28","updated_at":"2016-09-22 16:20:00"}]}
http://localhost/web/Laralum3/public/api/apify/users/email/ConsoleTVs@gmail.com,ConsoleTV3s@gmail.com (example URL)
{"users":[{"id":1,"name":"\u00c8rik Campobadal","email":"ConsoleTVs@gmail.com","created_at":"2016-09-22 16:13:28","updated_at":"2016-10-02 11:18:25"},{"id":3,"name":"Third User","email":"ConsoleTV3s@gmail.com","created_at":"2016-08-22 16:13:28","updated_at":"2016-09-22 16:20:00"}]}

The Versions

09/10 2017

dev-master

9999999-dev

API generator for laravel 5

  Sources   Download

MIT

The Requires

 

09/11 2016

1.0

1.0.0.0

API generator for laravel 5

  Sources   Download

MIT

The Requires

 

09/11 2016

dev-analysis-8Ab0eB

dev-analysis-8Ab0eB

API generator for laravel 5

  Sources   Download

MIT

The Requires