brieucthomas / ergast-client
PHP client for Ergast Developer API
v1.0.1
2020-09-09 14:09 UTC
Requires
- php: >=7.0
- doctrine/collections: ^1.0
- guzzlehttp/guzzle: ^6.0
- jms/serializer: ^1.5
- psr/http-message: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpunit/phpunit: ^5.0
This package is not auto-updated.
Last update: 2024-12-26 10:09:05 UTC
README
PHP client for Ergast Developer API.
Requirements
PHP needs to be a minimum version of PHP 7.
Installation
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.
Usage
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
Limit and offset
$uriBuilder ->setFirstResult(2) ->setMaxResults(5) ;