PHP code example of corsinvest / cv4pve-api-php

1. Go to this page and download the library: Download corsinvest/cv4pve-api-php 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/ */

    

corsinvest / cv4pve-api-php example snippets



Corsinvest\ProxmoxVE\Api\PveClient;

$client = new PveClient("your-proxmox-host.com");

if ($client->login('root', 'password', 'pam')) {
    // Get cluster status
    $status = $client->getNodes()->get("pve1")->getStatus()->current();
    echo "Node Status: " . $status->getResponse()->data->status . "\n";
    
    // List VMs
    foreach ($client->getNodes()->get("pve1")->getQemu()->vmlist()->getResponse()->data as $vm) {
        echo "VM {$vm->vmid}: {$vm->name} - Status: {$vm->status}\n";
    }
}
text
   ______                _                      __
  / ____/___  __________(_)___ _   _____  _____/ /_
 / /   / __ \/ ___/ ___/ / __ \ | / / _ \/ ___/ __/
/ /___/ /_/ / /  (__  ) / / / / |/ /  __(__  ) /_
\____/\____/_/  /____/_/_/ /_/|___/\___/____/\__/

Corsinvest for Proxmox VE Api Client  (Made in Italy 🇮🇹)
bash
composer