PHP code example of tobischulz / laravel-respawnhost-sdk

1. Go to this page and download the library: Download tobischulz/laravel-respawnhost-sdk 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/ */

    

tobischulz / laravel-respawnhost-sdk example snippets


return [
    'base_url' => env('RESPAWNHOST_BASE_URL', 'https://respawnhost.com/api/v1'),
    'api_key' => env('RESPAWNHOST_API_KEY'),
    'timeout' => (int) env('RESPAWNHOST_TIMEOUT', 30),
    'connect_timeout' => (int) env('RESPAWNHOST_CONNECT_TIMEOUT', 10),
    'retry' => [
        'times' => (int) env('RESPAWNHOST_RETRY_TIMES', 1),
        'sleep' => (int) env('RESPAWNHOST_RETRY_SLEEP', 200),
    ],
    'user_agent' => env('RESPAWNHOST_USER_AGENT', 'laravel-respawnhost-sdk'),
    'catalog_base_url' => env('RESPAWNHOST_CATALOG_BASE_URL', 'https://respawnhost.com'),
];

use TobiSchulz\LaravelRespawnHostSdk\Facades\RespawnHost;

$servers = RespawnHost::servers()->all(['page' => 1, 'limit' => 10]);
$server = RespawnHost::servers()->find('server-uuid');
$serverWithPanelData = RespawnHost::servers()->find('server-uuid', 

use TobiSchulz\LaravelRespawnHostSdk\Facades\RespawnHost;

$result = RespawnHost::rent(
    gameShort: 'enshrouded', // / optional
    templateVersionId: null, // optional
    instanceCount: 1,        // optional, min 1
);

use TobiSchulz\LaravelRespawnHostSdk\Facades\RespawnHost;

// list<CatalogGame>
$games = RespawnHost::allGames();

// CatalogGame
$game = RespawnHost::gameByShort('v-rising');

// list<CatalogGamePackage>
$packages = RespawnHost::packagesByGameShort('v-rising');

$payments = RespawnHost::payments()->all(['page' => 1]);
$invoice = RespawnHost::payments()->downloadInvoice(123);

$transactions = RespawnHost::transactions()->all();
$transaction = RespawnHost::transactions()->find(456);

$response = RespawnHost::request(
    method: 'GET',
    uri: '/api/v1/servers/server-uuid/files',
    query: ['directory' => '/']
);

use TobiSchulz\LaravelRespawnHostSdk\Exceptions\RespawnHostRequestException;

try {
    RespawnHost::transactions()->all();
} catch (RespawnHostRequestException $exception) {
    $status = $exception->response()->status();
    $body = $exception->response()->json();
}
bash
php artisan vendor:publish --tag="laravel-respawnhost-sdk-config"