A typed PHP client for the EventIO API (v2).
Add the repository to your composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "git@github.com:RestartITServices/eventio-api-client.git"
}
]
}Then require the package:
composer require eventio/php-api-clientuse EventIO\ApiClient\Client;
$client = new Client(baseUrl: 'https://book.your-event.com', token: 'your-api-token');// List all events (paginated)
$events = $client->events()->list()->get();
foreach ($events->items() as $event) {
echo $event->name;
}
// Get a single event
$event = $client->event(1)->get();$bookings = $client->event(1)->bookings()
->list()
->include('tickets', 'group')
->filter('status', 'confirmed')
->sort('-created_at')
->get();
foreach ($bookings->items() as $booking) {
echo $booking->bookingReference;
}
// Single booking
$booking = $client->event(1)->bookings()->get(42);$tickets = $client->event(1)->tickets()->list()->get();
$ticket = $client->event(1)->tickets()->get(5);$groups = $client->event(1)->groups()->list()->get();
$group = $client->event(1)->groups()->get(3);
// Group bookings, participants and the users who manage the group
$bookings = $client->event(1)->groups()->bookings(groupId: 3)->get();
$participants = $client->event(1)->groups()->participants(groupId: 3)->get();
$users = $client->event(1)->groups()->users(groupId: 3)->get();$participants = $client->event(1)->participants()->list()->filter('group_id', 3)->get();
$participant = $client->event(1)->participants()->get('participant-key');
$participant = $client->event(1)->participants()->getByWristband('1001');Gates can be addressed by id or by gate_key.
$gates = $client->event(1)->gates()->list()->filter('enabled', 1)->get();
$gate = $client->event(1)->gates()->get('main-entrance');
$occupancy = $client->event(1)->gates()->occupancy(3);
$roster = $client->event(1)->gates()->roster(3)->get();
// Passage history, newest first
$passages = $client->event(1)->gates()->passages(3, from: new DateTimeImmutable('-1 day'), perPage: 100)->get();
$passages = $client->event(1)->gates()->participantPassages(participantId: 7)->get();$stats = $client->event(1)->stats();
echo $stats->totalConfirmed;
echo $stats->totalProvisional;use EventIO\ApiClient\Enums\NotificationType;
use EventIO\ApiClient\Requests\CreateNotificationRequest;
$notifications = $client->event(1)->notifications()->list()->get();
$notification = $client->event(1)->notifications()->create(
new CreateNotificationRequest(
title: 'Hello',
content: 'Notification body',
type: NotificationType::InApp,
)
);$roles = $client->event(1)->roles()->list()->get();
$users = $client->event(1)->users()->list()->get();$user = $client->user();
// or scoped to an event, with the role held on it
$user = $client->user(eventId: 1);
$user = $client->event(1)->user();$client->ping(); // "API is working"
$client->version(); // API version stringAll list() methods return a QueryBuilder that supports fluent chaining:
$results = $client->event(1)->bookings()
->list()
->filter('status', 'confirmed')
->sort('-created_at', 'booking_reference')
->include('tickets', 'group')
->get();get() returns a PaginatedResponse that automatically fetches subsequent pages:
$response = $client->event(1)->bookings()->list()->get();
// Lazy iteration — fetches pages as needed
foreach ($response->items() as $booking) {
// ...
}
// Or load everything into an array
$all = $response->toArray();
// Get just the first item
$first = $response->first();
// Access pagination metadata
$meta = $response->meta(); // ['current_page' => 1, 'last_page' => 5, 'total' => 100, ...]The client throws typed exceptions for API errors:
| Exception | HTTP Status | Description |
|---|---|---|
AuthenticationException |
401 | Invalid or missing API token |
AuthorizationException |
403 | Insufficient permissions |
NotFoundException |
404 | Resource not found |
ValidationException |
422 | Validation errors (access via ->errors) |
ServerException |
500 | Server error |
EventIOException |
— | Base exception / generic HTTP failure |
use EventIO\ApiClient\Exceptions\NotFoundException;
use EventIO\ApiClient\Exceptions\ValidationException;
try {
$booking = $client->event(1)->bookings()->get(999);
} catch (NotFoundException $e) {
// Resource doesn't exist
} catch (ValidationException $e) {
$e->errors; // ['field' => ['Error message']]
}# Run tests
vendor/bin/pest
# Static analysis
vendor/bin/phpstan analyse