Soon, we’ll be announcing a fresh new marketplace for TastyIgniter developers.

APIs Created by: Sam Poyigi

 77

Manages and generates RESTful APIs using available models

Reviews should not be used for getting support.

  Extension   Public repository
Version
v0.1.0-beta.7
Updated
22 hours ago
Author
Sam Poyigi

Views: 30

Support the author with a donation.

  Donate

APIs is an extension that allows you to build RESTful APIs and manage them within a TastyIgniter application.

However, it accomplishes more than just that, you may override the api actions (verbs) with your own logic. Default behavior logic for several common verbs are supported — create, store, show, edit, update, destroy.

Features

  • Auto Generate Controller (CRUD)
  • Auto Generate Resource Response Class (For modeling JSON response)
  • Support relationships

TO DO:

  • User Authentication (with Laravel Passport)
  • Generating User Tokens

Usage

In the admin user interface, go to Tools > APIs and use the Create button to generate a new api resource

Manually Create an API resource

The below command will generate both Controller and Resource Transformer for the specified resource

php artisan create:apiresource Acme.Extension ResourceName

After the resource has been generated, add it to routes by registering a new api resource.

Register API Resource

public function registerApiResources()
{
    return [
        'menus' => [
            'name' => 'Menus',
            'description' => 'Description of this API resource',
            'controller' => \Acme\Extension\Resources\Menus::class,
            'transformer' => \Acme\Extension\Resources\Transformers\MenuTransformer::class,
        ],
    ];
}

The array keys represents the resource endpoints

Resource Transformer

Response are transformed using laravel's eloquent resources.

Example of Resource Transformer

<?php namespace Igniter\Api\Resources\Transformers;

use Illuminate\Http\Resources\Json\Resource;

class MenuTransformer extends Resource
{
    public function toArray($request)
    {
        return [
            'id'      => (int) $this->menu_id,
            'name'    => $this->menu_name,
            'links'   => [
                [
                    'rel' => 'self',
                    'uri' => '/api/menus/'.$this->menu_id,
                ]
            ],
        ];
    }
}

Versions

  1. v0.1.0-beta.7

    Minor changes

  2. master

  3. v0.1.0-beta.6

  4. v0.1.0-beta.6