Download the PHP package sedp-mis/base-api without Composer
On this page you can find all versions of the php package sedp-mis/base-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sedp-mis/base-api
More information about sedp-mis/base-api
Files in sedp-mis/base-api
Package base-api
Short Description Abstraction for api resources in laravel
License MIT
Informations about the package base-api
SedpMis\BaseApi
Abstraction for api resources in Laravel. Compatible to use with Laravel 4.2
and 5.*
.
Installation
Use composer to install base-api and dependencies:
Introduction
The purpose of this repository is to create an abstraction for common use-cases of api resources.
It is a good practice to version our api so we will set our base api to api/v1
.
So in the following api implementations, the example resource to be used is posts
.
Implementation
METHOD | URL | Description |
---|---|---|
GET |
api/v1/posts |
@index , List of resources |
POST |
api/v1/posts |
@store , Create or store new resource |
GET |
api/v1/posts/{id} |
@show , Show resource |
PUT|PATCH |
api/v1/posts/{id} |
@update , Update resource |
DELETE |
api/v1/posts/{id} |
@destroy , Destroy or delete resource |
Notice that @<method>
are the same with the controller methods in laravel.
Advance Implementation for GET
methods like @index
and @show
.
@index
and @show
-
Selective Attributes. Resource can be fetched with selective or specific fields or attributes by using query parameter
attributes[]
. Example: -
Relations. Resource can be fetched with eager loaded relations by using query parameter
relations[]
. Example: - Relations Attributes. Fetched eager loaded relations can also have selective or specific attributes. Example:
@index
-
Pagination. For list of resources, it is recommended to have it paginated:
This example shows that it is currently on the 1st page and showing 100 records per page. Without
page
parameter, the list will default to all resources to be fetched. -
Filtering. It is also handy to filter list by its attributes using
filters[attribute][]
parameter.-
Default:
-
Using
equals
operator (behaves like the default example): - Using
not_equals
operator:
-
-
Searching. It is also possible to search by passing
search
query parameter. - Sorting. Sorting can be done by this syntax
sort[attribute_1]=asc&sort[attribute_n]=desc
. Example:
All versions of base-api with dependencies
laravel/framework Version >=4.2.11
sedp-mis/lib Version 1.*
sedp-mis/base-repository Version 0.*