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
|
Name: |
Laravel REST API |
Base name: |
lara_rest |
Description: |
Create an API using Laravel Eloquent models |
Version: |
1.0.0 |
PHP version: |
5 |
License: |
GNU General Public License (GPL) |
All time users: |
70 users |
All time rank: |
10100 |
Week users: |
0 users |
Week rank: |
284  |
|
|
 February 2022
Number 4 |
Many Web applications provide APIs to expose their functionalities to external applications.
Usually, those applications provide a REST API to manipulate information records stored in databases accessed using model classes.
This package makes it simpler to create complex REST API by reducing the effort to write code to set up and configure REST APIs that provide access to many model classes in the same API provided by applications written with the Laravel framework.
Manuel Lemos |
Not yet rated by the users |
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.
|
Files |
|
|
Files |
|