prolificjones / elite-league-client
Elite League API SDK in PHP
Requires
- guzzlehttp/guzzle: ^8.3
- monolog/monolog: ^3.12
- psr/clock: ^1.0
- symfony/http-foundation: ^8.1
Requires (Dev)
- php: ^8.4
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.4
- symfony/dotenv: ^8.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-23 12:28:52 UTC
README
A PHP client for reading Elite Ice Hockey League (EIHL) schedules, standings, match information, and match statistics from the Elite League API.
The SDK sends requests to the API's public JSON endpoint and maps responses to typed, immutable PHP response objects.
Requirements
- PHP 8.4 or later
- Composer
Installation
Install the package with Composer:
composer require prolificjones/elite-league-client
Composer's autoloader uses the EliteLeagueClient\\ namespace for classes in this package. Include it in a standalone script when it is not already loaded by your application:
require __DIR__ . '/vendor/autoload.php';
Quick start
Each API area has its own client. The methods return response objects rather than raw JSON:
<?php require __DIR__ . '/vendor/autoload.php'; use EliteLeagueClient\Game\Game; use EliteLeagueClient\Schedule\Enums\League; use EliteLeagueClient\Schedule\GameSchedule; use EliteLeagueClient\Standings\Standings; $league = League::EIHL; $season = 2025; $schedule = (new GameSchedule())->getLeagueSchedule($league, $season); foreach ($schedule->matches as $match) { printf( "%s: %s vs %s (%s)\n", $match->start_date->format('Y-m-d H:i'), $match->home->name, $match->guest->name, $match->status->value, ); } $standings = (new Standings())->getStandings($league, $season); foreach ($standings->clubs as $club) { printf("%d. %s - %d points\n", $club->position, $club->name, $club->points); } $game = (new Game())->getGameAndRoster(12345); printf("%s vs %s\n", $game->teamInfo->home->name, $game->teamInfo->visitor->name);
Replace 2025 and 12345 with the season and match ID you want to query. Season values are passed through to the API as supplied.
Clients and methods
All clients accept an optional array of additional HTTP headers. The SDK supplies Cache-Control: no-cache and Content-Type: application/json by default.
Schedule
use EliteLeagueClient\Schedule\Enums\League; use EliteLeagueClient\Schedule\GameSchedule; $client = new GameSchedule(); $leagueSchedule = $client->getLeagueSchedule(League::EIHL, 2025); $teamSchedule = $client->getTeamSchedule(League::EIHL, 96, 2025);
| Method | Description | Response |
|---|---|---|
| `getLeagueSchedule(League $league, int | string $year)` | All listed games for a league and season |
| `getTeamSchedule(League $league, int | string $team, int | string $year)` |
ScheduleResponse::$matches contains ScheduleGameResponse objects. A match includes its ID, start date (DateTime), league and season, home and guest teams, status, results, venue, and game-clock metadata.
Standings
use EliteLeagueClient\Schedule\Enums\League; use EliteLeagueClient\Standings\Standings; $standings = (new Standings())->getStandings(League::EIHL, 2025); foreach ($standings->clubs as $club) { echo $club->name . ': ' . $club->points . " points\n"; }
getStandings(League $league, int|string $year) returns a StandingsResponse. It contains optional group metadata, a completion flag, and clubs, an array of team response objects with position, points, games played, results, and scoring fields.
Match information and statistics
use EliteLeagueClient\Game\Game; $client = new Game(); $info = $client->getGameAndRoster(12345); $events = $client->getGameEvents(12345); $playerStats = $client->getPlayerStats(12345, 96); $goalieStats = $client->getGoalieStats(12345); $teamStats = $client->getTeamStats(12345, 96);
| Method | Description | Response |
|---|---|---|
| `getGameAndRoster(int | string $game_id)` | Match details, score, teams, officials, and rosters |
| `getGameEvents(int | string $game_id)` | Events grouped by period, overtime, and shootout |
| `getPlayerStats(int | string $game_id, int | string $team_id)` |
| `getGoalieStats(int | string $game_id)` | Goalie statistics for a match |
| `getTeamStats(int | string $game_id, int | string $team_id)` |
The response classes expose their fields as public, typed, readonly properties. Nested values are also response objects, and collections contain mapped response objects rather than untyped JSON arrays.
League and game status enums
Pass a League enum case to schedule and standings methods:
| Case | API value |
|---|---|
League::EIHL |
3 |
League::CHALLENGE_CUP |
4 |
League::PLAYOFFS |
5 |
Schedule matches expose their status as a GameStatus enum in $match->status. Its values are Fixture, Live, Result, Postponed, Interupted, and Cancelled. API spellings such as INTERRUPTED and CANCELED are normalized when mapping responses.
Working with responses
All response DTOs implement ReadonlyInterface, with toArray() for converting a response (including nested response objects) to arrays and fromArray() for constructing one from API-shaped data:
$data = $schedule->toArray(); $firstMatch = $data['matches'][0] ?? null;
Date fields are represented as DateTime objects on the response and formatted back to API-style strings by toArray().
HTTP headers
Pass extra or overriding headers when constructing a client:
$client = new Game([ 'X-Application' => 'my-hockey-app', ]);
These are merged with the default headers. The base API URL is configured by the SDK.
Logging
The SDK writes logs to ./elite-league-sdk.log (relative to the process working directory) and also configures a FirePHP handler. By default, handlers log errors and more severe messages. To enable verbose logging, set ELITE_LEAGUE_VERBOSE_LOGGING to a boolean-like value such as true, 1, yes, or on:
ELITE_LEAGUE_VERBOSE_LOGGING=true php app.php
Verbose mode enables debug-and-higher messages, including request metadata. Since request context can include configured header values, protect the log file and avoid verbose mode where those values should not be recorded. Invalid values for ELITE_LEAGUE_VERBOSE_LOGGING raise an InvalidArgumentException.
Errors
HTTP request failures are logged and rethrown as exceptions. Connection failures and response-mapping or JSON-decoding errors are also allowed to propagate; callers should handle exceptions at an appropriate application boundary:
try { $schedule = (new GameSchedule())->getLeagueSchedule(League::EIHL, 2025); } catch (\Throwable $exception) { error_log(sprintf('Unable to load the league schedule: %s', $exception->getMessage())); throw $exception; }
Development
Install development dependencies and run the test suite:
composer install
composer test
Formatting can be checked with:
composer format:check
License
This package is licensed under the GNU General Public License v3.0 or later.