PHP code example of seatplus / esi-client

1. Go to this page and download the library: Download seatplus/esi-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

seatplus / esi-client example snippets


use Seatplus\EsiClient\EsiClient;

$sdk = new EsiClient();

// Single object — returns AllianceDetail directly
$alliance = $sdk->alliance()->getAlliancesAllianceId(99000006);
echo $alliance->name;          // typed readonly string
echo $alliance->ticker;
$alliance->isCachedLoad;       // bool — true if served from RFC 7234 cache

// Authenticated endpoint — returns CharactersDetail directly
$character = $sdk->withToken($accessToken)->characters()->getCharactersDetail(95725047);
echo $character->name;

// Paginated list — returns EsiResult (pages metadata needed)
$result = $sdk->withToken($accessToken)->assets()->getCharactersCharacterIdAssets(95725047, page: 1);
echo $result->pages;           // total pages from X-Pages header
foreach ($result->data as $asset) {
    echo $asset->item_id;      // typed readonly int
}

$esi = new EsiClient();

// make a call — returns EsiResponse
$response = $esi->invoke('get', '/characters/{character_id}/', [
    'character_id' => 95725047,
]);

// $response->data    — stdClass decoded from the JSON body
// $response->pages   — total pages (from X-Pages header, or 1)
// $response->isCachedLoad() — true if served from RFC 7234 cache

try {
    $sdk->withToken($accessToken)->characters()->getCharactersDetail(95725047);
} catch (EsiRateLimitedException $e) {
    // back off for $e->retryAfter seconds
} catch (EsiTransportException $e) {
    // the ESI was unreachable — retry later
} catch (EsiClientException $e) {
    // anything else this package throws
}
bash
> php -r '