PHP client for Ergast Developer API.
PHP needs to be a minimum version of PHP 7.
This library can be easily installed via Composer:
composer require brieucthomas/ergast-client
or just add it to your composer.json
file directly and run composer install.
use BrieucThomas\ErgastClient\ErgastClientBuilder;
use BrieucThomas\ErgastClient\Request\RequestBuilder;
$ergastClient = ErgastClientBuilder::createErgastClient();
$requestBuilder = new RequestBuilder();
$requestBuilder
->findCircuits()
->byId('monza')
;
$response = $ergastClient->execute($requestBuilder->build());
$circuit = $response->getCircuits()->first();
echo $circuit->getId(); // "monza"
echo $circuit->getName(); // "Autodromo Nazionale di Monza"
echo $circuit->getUrl(); // "http://en.wikipedia.org/wiki/Autodromo_Nazionale_Monza"
echo $circuit->getLocation()->getLocality(); // "Monza"
echo $circuit->getLocation()->getCountry(); // "Italy"
echo $circuit->getLocation()->getLatitude(); // 45.6156
echo $circuit->getLocation()->getLongitude(); // 9.28111
$uriBuilder
->setFirstResult(2)
->setMaxResults(5)
;