Download the PHP package bauer01/unimapper-nette without Composer
On this page you can find all versions of the php package bauer01/unimapper-nette. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package unimapper-nette
Unimapper Nette extension
Official Unimapper extension for Nette framework.
Install
Nette 2.1 and higher
Register extension in config.neon
.
Nette 2.0
Register extension in app/bootstrap.php
.
Configuration
API
Creating new API for your application is very easy, all you need is presenter for every entity you have.
Remember that every API presenter should always extend UniMapper\Nette\Api\Presenter.
Now you can call standard API methods like:
GET
- associate - common parameter used to tell which association should be included in response. Syntax should be like
?associate[]=property1&associate[]=property2
or?associate=property1,property2
.
Response
/api/entity/id
Get a single record.
/api/entity
Get all records.
- count - optional parameter, if
?count=true
set then items count number will be returned in response body instead data. - limit - maximum limit is set to
10
. You can change it by overriding property$maxLimit
in your API presenter descendant. - offset
- where
PUT
/api/entity
Update all records with JSON data stored in request body. Filtering can be set and response body contains number of affected records.
- where
Response
/api/entity/id
Update single record with JSON data stored in request body.
Response
POST
Create new record with JSON data stored in request body and primary value of new entity returned in response body.
/api/entity
Response
DELETE
/api/entity
Delete all records returned body contains number of deleted records.
- where
Response
/api/entity/id
Delete single record.
Response
Custom API methods
You can even define your custom method.
Then you can make a requests like /api/entity/1?action=yourCustomMehod
.
Filtering data
Filter can be set as a GET parameter where
in URL. It should be here a valid JSON format as described here.
Error response
If some bad request detected or an error occurred the returned response can be like this:
Generating links
In your templates just use standard Nette link macro.
{link :Api:Entity:get}
{link :Api:Entity:get 1}
{link :Api:Entity:put 1}
{link :Api:Entity:post}
{link :Api:Entity:action}
Usage
You can even build another applications using this API, just register an official API adapter class UniMapper\Nette\Api\Adapter
in your config.neon.
Custom request factory
For easier API queries you can register factory interface as a dynamic service in your config.neon.
Usage in your reopistory can look like this:
All versions of unimapper-nette with dependencies
ext-curl Version *