Method URL Action
GET /api/wines Retrieve all wines
GET /api/wines/search/Chateau Search
for
wines with ‘Chateau’ in their name
GET /api/wines/10 Retrieve wine with id == 10
POST /api/wines Add a
new
wine
PUT /api/wines/10 Update wine with id == 10
DELETE
/api/wines/10
Delete
wine with id == 10
Implementing the API with Slim
Slim makes it easy to implement this API in PHP:
<?php
require
'Slim/Slim.php'
;
$app
=
new
Slim();
$app
->get(
'/wines'
,
'getWines'
);
$app
->get(
'/wines/:id'
,
'getWine'
);
$app
->get(
'/wines/search/:query'
,
'findByName'
);
$app
->post(
'/wines'
,
'addWine'
);
$app
->put(
'/wines/:id'
,
'updateWine'
);