PHP code example of github-aiko / php-virtualizor

1. Go to this page and download the library: Download github-aiko/php-virtualizor 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/ */

    

github-aiko / php-virtualizor example snippets




irtualizor\Virtualizor;

// Initialize with your Virtualizor credentials
$virtualizor = new Virtualizor(
    'your-server-ip',    // Server IP
    'your-api-key',      // API Key  
    'your-api-pass',     // API Password
    '4085',              // Admin Port (default: 4085)
    '4083'               // Client Port (default: 4083)
);

// Get VirtualServer instance
$server = $virtualizor->server();

// List all virtual servers
$servers = $server->listAll();

// Get specific VPS info
$vpsInfo = $server->info($vpsId);

// Start/Stop/Restart VPS
$server->start($vpsId);
$server->stop($vpsId);
$server->restart($vpsId);

// Get OS Templates instance
$templates = $virtualizor->osTemplates();

// List all available templates
$allTemplates = $templates->listAll();

// Get IP Pool instance
$ipPool = $virtualizor->IPPool();

// List all IP pools
$pools = $ipPool->listAll();

// Get Users instance
$users = $virtualizor->Users();

// List all users
$allUsers = $users->listAll();
bash
composer