Resurrecting the topic, I found this library https://github.com/Respect/Rest/ is very easy to use, but there are few examples on the web:
require_once 'bootstrap.php';
require_once 'Respect/Rest/Router.php';
require_once 'Respect/Rest/Request.php';
use Respect\Rest\Router;
$router->post('/myApp/', function() {
$data_back = json_decode(file_get_contents('php://input'));
// var_dump($data_back);
return json_encode($data_back);
});
$router->get('/myApp/*', function($id = null) {
$json = json_encode(MyService::getInstance()->list());
return utf8_encode($json);
});
$router->put('/myApp/*', function($id = null) {
return 'Update: ' . $id;
});
$router->delete('/myApp/*', function($id = null) {
return 'Delete: ' . $id;
});