1. Go to this page and download the library: Download atog/simple-api-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/ */
atog / simple-api-client example snippets
class Client extends \Atog\Api\Client
{
protected $domain = 'http://example.com/api/v1';
}
class TestEndpoint extends \Atog\Api\Endpoint
{
protected $endpoint = 'foo';
public function find($slug)
{
// https://example.com/api/v1/foo/$slug gets called
$this->respond(
$this->client->get($this->getEndpointUrl($slug, true))
);
}
}
class TestModel extends Model
{
public function getNameAttribute($value)
{
return strtoupper($value);
}
public function setFirstNameAttribute($value)
{
$this->attributes['first_name'] = strtolower($value);
}
public function setContactsAttribute($value)
{
$this->attributes['contacts'] = $this->makeCollection($value, Contacts::class);
}
}