Here is an example that defines and executes your Symfony route:
{
"operations": {
"deleteEntity": {
"httpMethod": "DELETE",
"uri": "/userapi/delete/{userid}/{apiid}",
"summary": "Deletes an entity",
"parameters": {
"userid": {
"location": "query"
},
"apiid": {
"location": "query"
}
}
}
}
}
and the code:
class MyApi
{
protected $client;
public function __construct(ClientInterface $client, $baseUrl)
{
$this->client = $client;
//tell the client what the base URL to use for the request
$this->client->setBaseUrl($baseUrl);
//fill the client with all the routes
$description = ServiceDescription::factory("/path/to/routes.json");
$this->client->setDescription($description);
}
public function deleteEntity($userId, $apiId)
{
$params = array(
'userid' => $userId,
'apiid' => $apiId
);
$command = $this->client->getCommand('deleteEntity', $params);
$command->prepare();
$response = $this->client->execute($command);
return $response;
}
}
$client = new Guzzle\Service\Client();
$api = new MyApi($client, ' http://localhost/us/serenify/web/app_dev.php');
$api->deleteEntity(1, 6);
Now, as it currently stands, the generated route would look something like
http://localhost/us/serenify/web/app_dev.php/userapi/delete?userid=1&apiid=6.
If you want the parameters not to be passed by Guzzle as query paramters, but instead like URL parameters, all you have to do is change their type in the JSON definition file from query to uri.
PS: I did NOT test the code above. Might work out-of-the-box or it might not. Minor tweaks may be required.