PHP code example of timostamm / json-client
1. Go to this page and download the library: Download timostamm/json-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
timostamm / json-client example snippets
class MyClient extends AbstractApiClient {
/**
* @throws TransferException
*/
public function send(Model $model):void
{
// The data will automatically be
// serialized to JSON.
$this->http->post('model', [
'data' => $model
]);
}
/**
* @param int $id
* @throws TransferException
* @returns Model
*/
public function get(int $id):Model
{
return $this->http->get('model/'.$id, [
'deserialize_to' => Model::class
]);
}
}