2017 © Pedro Peláez
 

library pterodactyl-sdk

Pterodactyl PHP SDK (Unofficial)

image

fruitbytes/pterodactyl-sdk

Pterodactyl PHP SDK (Unofficial)

  • Friday, May 18, 2018
  • by FruitBytes
  • Repository
  • 3 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 13 % Grown

The README.md

Pterodactyl PHP SDK

Latest Version on Packagist Total Downloads ![Software License][ico-license], (*1)

To install the SDK in your project you need to require the package via composer:, (*2)

composer require fruitbytes/pterodactyl-sdk

Then use Composer's autoload:, (*3)

require __DIR__.'/../vendor/autoload.php';

And finally create an instance of the SDK:, (*4)

$pterodactyl = new \Fruitbytes\Pterodactyl\Pterodactyl(PUBLIC_KEY_HERE, SECRET_KEY_HERE, BASE_URI_HERE);

Usage

Using the pterodactyl instance you may perform multiple actions as well as retrieve the different resources Pterodactyl's API provides:, (*5)

$servers = $pterodactyl->servers();

This will give you an array of servers that you have access to, each server is represented by an instance of Fruitbytes\Pterodactyl\Resources\Server, this instance has multiple public properties like $name, $id, $owner, $memory, and others., (*6)

You may also retrieve a single server using:, (*7)

$server = $pterodactyl->server(SERVER_ID_HERE);

On multiple actions supported by this SDK you may need to pass some parameters, for example when creating a new server:, (*8)

$server = $pterodactyl->createServer([
    "name"=>"API Test",
    "description"=>"API Description",
    "user_id"=>1,
    "location_id"=>1,
    "auto_deploy"=>true,
    "memory"=>64,
    "swap"=>0,
    "disk"=>1024,
    "cpu"=>0,
    "io"=>500,
    "service_id"=>1,
    "option_id"=>1,
    "startup"=>"java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}",
    "env_SERVER_JARFILE"=>"server.jar",
    "env_VANILLA_VERSION"=>"latest"
]);

These parameters will be used in the POST request sent to Pterodactyl servers, you can find more information about the parameters needed for each action on Pterodactyl's official API documentation., (*9)

Notice that this request for example will only start the server creation process, your server might need a few minutes before it completes provisioning, you'll need to check the Server's $installed property to know if it's ready or not yet., (*10)

Managing Users

$pterodactyl->users();
$pterodactyl->user($userId);
$pterodactyl->createUser(array $data);
$pterodactyl->deleteUser($userId);

On a User instance you may also call:, (*11)

$user->delete();

Managing Servers

$pterodactyl->servers();
$pterodactyl->server($serverId);
$pterodactyl->createServer(array $data);
$pterodactyl->deleteServer($serverId);

// Server access
$pterodactyl->suspendServer($serverId);
$pterodactyl->unsuspendServer($serverId);

On a Server instance you may also call:, (*12)

$server->delete();
$server->suspend();
$server->unsuspend();

Using Servers

$pterodactyl->powerServer($serverUuid, $action); // 'start', 'stop', 'restart', 'kill'
$pterodactyl->commandServer($serverUuid, $command);

On a Server instance you may also call:, (*13)

$server->power($action); // 'start', 'stop', 'restart', 'kill'
$server->command($command);

License

fruitbytes/pterodactyl-sdk is licensed under the MIT License (MIT). Please see the license file for more information., (*14)

The Versions

18/05 2018

dev-master

9999999-dev

Pterodactyl PHP SDK (Unofficial)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Josh Trebilco

php sdk pterodactyl

17/04 2018

dev-feature/nodes

dev-feature/nodes

Pterodactyl PHP SDK (Unofficial)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Josh Trebilco

php sdk pterodactyl