PHP code example of jaeger / solusvm-client

1. Go to this page and download the library: Download jaeger/solusvm-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/ */

    

jaeger / solusvm-client example snippets


$vm = new \Jaeger\SolusVm([
    //SolusVM server api url - 服务器SolusVM控制面板的API地址 
    'server_api_url' => 'https://xxxx.com/api/client/command.php',
    //API Key
    'key' => '*****',
    //API Hash
    'hash' => '*****'
]);

//reboot server - 重启服务器
$rt = $vm->reboot();
//$rt = $vm->action('reboot');

//shutdown server - 服务器关机
$rt = $vm->shutdown();

//boot server - 服务器开机
$rt = $vm->boot();

//get server status - 获取服务器状态(是否在线)
$rt = $vm->status();

$rt = $vm->shutdownAndBoot();

//Check if the server is ofline, and reboot the server if the ofline
//检测服务器是否拓机,如果拓机则重启服务器
$rt = $vm->checkAndReboot();



$vm = new \Jaeger\SolusVm([
    'server_api_url' => 'https://xxxx.com/api/client/command.php',
    'key' => '*****',
    'hash' => '*****',

    //log path - 日志文件路径
    'log' => './log/vm.log'
]);

//or 

$logHandler = new \Monolog\Handler\StreamHandler('./log/vm.log',\Monolog\Logger::INFO);

$vm = new \Jaeger\SolusVm([
       'server_api_url' => 'https://xxxx.com/api/client/command.php',
       'key' => '*****',
       'hash' => '*****',

       //log handler
       'log' => $logHandler
]);