PHP Classes

Laravel REST API: Create an API using Laravel Eloquent models

Recommend this page to a friend!

  Author Author  
Picture of Raskin Veniamin
Name: Raskin Veniamin <contact>
Classes: 12 packages by
Country: Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 6x

Winner: 1x


  Detailed description   Download Download .zip .tar.gz  
This package can create REST API applications using Laravel Eloquent models.

It can perform several steps to configure API handler classes to call model classes to generate the values used to respond to REST API requests.

Currently, it can:

- Register a service provider class

- Mapping API request parameters to model classes that will handle the access to model objects

- Perform operations to customize the REST API requests

- Configure the mapping of request URL parameters to API request routes.

Details

Lp api rest

This package allows you to create a simple REST API on the basis of standard models (Eloquent) of the Larave 5.x Framework.

install

  • composer require venya/lp-rest

Configure

  • Add app.php

    $app->register(LpRest\RestServiceProvider::class);

    //$app->register(LpRest\RestServiceProviderLumen::class); //for Lumen

  • Add in AppServiceProvider::register

    //Set model aliases app()->afterResolving(CommonRepositoryModelProvider::class, function(CommonRepositoryModelProvider $mp) { $mp->addModelAliases('user', \App\User::class); });

    //Change access provider $this->app->bind(CommonRepositoryAccessProvider::class, ApiAccessProvider::class );

    //Change response schema $this->app->bind(CommonResponse::class, ApiCustomResponse::class );

    //Custom routes and etc $this->app->afterResolving(RestServiceHelper::class, function(RestServiceHelper $sp) { $sp->setRouteGroupOptions([ 'prefix' => 'api/rest', //'middleware' => 'auth', ]); });

API

  • GET /api/rest/:modelName[/:relations] - get all items
  • GET /api/rest/:modelName/:id[/:relations] - get one item
  • POST /api/rest/:modelName {:json body} - create item
  • PUT /api/rest/:modelName/:id {:json body} - update item
  • DELETE /api/rest/:modelName/:id - remove item
  • POST /api/rest/:modelName/:id {:json body - arguments} - Call model method
  • POST /api/rest/multi {:json body - config any query} - Causes several methods at a time

TODO FILTER DESCRIPTION

  • /api/rest/file?filter[]=created_at:range:2018-03-01,2018-05-20&filter[]=tags.id:1&filter[]=id:in:1,2,3,18

  Classes of Raskin Veniamin  >  Laravel REST API  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: Laravel REST API
Base name: lara_rest
Description: Create an API using Laravel Eloquent models
Version: -
PHP version: 5
License: GNU General Public License (GPL)
 
  Groups   Applications   Files Files  

  Groups  
Group folder image HTTP HTTP protocol clients, headers and cookies View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Libraries Frameworks and libraries of cooperating classes View top rated classes
Group folder image Web services Web data clipping, SOAP or XML-RPC clients and servers View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder imagesrc (3 files, 6 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageCommands (1 file)
Files folder imageControllers (3 files)
Files folder imageFacades (1 file)
Files folder imagemigrations (1 file)
Files folder imageModels (2 files)
Files folder imageRepositories (12 files)
  Plain text file RestServiceHelper.php Class Class source
  Plain text file RestServiceProviderLaravel.php Class Class source
  Plain text file RestServiceProviderLumen.php Class Class source

  Files folder image Files  /  src  /  Commands  
File Role Description
  Plain text file AccessFillCommand.php Class Class source

  Files folder image Files  /  src  /  Controllers  
File Role Description
  Plain text file CommonController.php Class Class source
  Plain text file CommonResponse.php Class Class source
  Plain text file CommonResponseBase.php Class Class source

  Files folder image Files  /  src  /  Facades  
File Role Description
  Plain text file CommonRepositoryAccessProvider.php Class Class source

  Files folder image Files  /  src  /  migrations  
File Role Description
  Plain text file 2018_03_12_092835_perm_group.php Class Class source

  Files folder image Files  /  src  /  Models  
File Role Description
  Plain text file RestAccess.php Class Class source
  Plain text file RestAccessUser.php Class Class source

  Files folder image Files  /  src  /  Repositories  
File Role Description
  Plain text file CommonRepository.php Class Class source
  Plain text file CommonRepositoryAccessProvider.php Class Class source
  Plain text file CommonRepositoryAccessProviderBase.php Class Class source
  Plain text file CommonRepositoryAccessProviderDB.php Class Class source
  Plain text file CommonRepositoryModel.php Class Class source
  Plain text file CommonRepositoryModelProvider.php Class Class source
  Plain text file CommonRepositoryModelProviderBase.php Class Class source
  Plain text file CommonRepositoryModelTrait.php Class Class source
  Plain text file Repository.php Class Class source
  Plain text file RepositoryProvider.php Class Class source
  Plain text file RepositoryProviderBase.php Class Class source
  Plain text file TraitRepositoryFilter.php Class Class source

Download Download all files: lara_rest.tar.gz lara_rest.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
For more information send a message to info at phpclasses dot org.