festivalslab / api-client-php
PHP client for the Edinburgh Festivals Listings API
Installs: 3 269
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- ergebnis/phpunit-slow-test-detector: ^2.15
- phpunit/phpunit: ^10.5
README
The Edinburgh Festivals Listings API client for PHP makes it easy for developers to access the Edinburgh Festivals Listings API in their PHP code.
You can get started quickly by installing the client through composer
Quick Examples
Create a client
// Require the Composer autoloader. require 'vendor/autoload.php'; use FestivalsApi\FestivalsApiClientFactory; // Instantiate a Festivals API Client. $client = FestivalsApiClientFactory::createWithCredentials('key', 'secret');
Find some events
use FestivalsApi\FestivalsApiClientException; try { $result = $client->searchEvents(['title' => 'Foo']); $events = $result->getEvents(); } catch (FestivalsApiClientException $e){ echo "There was an error: " . $e->getMessage(); }
Iterate all results
The API delivers results in pages, by default 25 results at a time, configurable up to 100.
Using FestivalsApi\FestivalsApiEventSearch
will take care for the pagination for you so you can iterate all results for a search query easily.
use FestivalsApi\EventSearchIterator; use FestivalsApi\FestivalsApiClientException; $search = new EventSearchIterator($client); $search->setQuery(['festival' => 'jazz']); try { foreach ($search as $event){ echo $event['title']; } } catch (FestivalsApiClientException $e){ echo "There was an error: " . $e->getMessage(); }
Resources
- API Docs - Details about parameters & responses
- API Browser - Interactive tool to explore API options and responses
Installing
The recommended way to install the php client is through Composer.
Install Composer https://getcomposer.org/
Next, run the Composer command to install the latest stable version of the client:
composer require festivalslab/api-client-php
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
You can then later update the client using composer:
composer update