ProxmoxVE_PHP_API
ProxmoxVE_PHP_API copied to clipboard
Non static method should not be called statically
Hi.
I saw you already closed related issue #19. But please check this issue.
Your functions doesn't marked as static method, but your README example wrote in static method usage.
It causes warning in PHP.
I confirmed that code works in static or non-static both. But class doesn't have constructor, so I think It will be called by static way always.
How about add static keyword to functions? Maybe I can open PR to this but you closed related issue in past so I open this issue first.
Thanks.
Hello in PHP 8.0. & 8.1. is this Nodes::setLxcFirewallOptions not allowed, there you have to do it like this: $Nodes->setLxcFirewallOptions
Complete example Create VM
require __DIR__ . '/vendor/autoload.php'; // Autoload files using Composer autoload
use Proxmox\Request;
use Proxmox\Cluster;
use Proxmox\Nodes;
$Nodes = new Nodes(); // NEW LINE
$Cluster = new Cluster(); // NEW LINE
$configure = [
'hostname' => '0.0.0.0',
'username' => 'root',
'password' => 'password',
];
Request::Login($configure); // Login ..
# Create VM
// $nextId = Cluster::nextVmid(); get next vmid - OLD LINE
$nextId = $Cluster->nextVmid(); // get next vmid - NEW LINE
$create = [
'vmid' => $nextId->data,
'cores' => 1,
'name' => 'testApi',
'scsi0' => 'local:32,format=qcow2'
];
# Get first node name.
// $firstNode = Nodes::listNodes()->data[0]->node; - OLD LINE
// print_r( Nodes::createQemu($firstNode, $create) ); - OLD LINE
$firstNode = $Nodes->listNodes()->data[0]->node; // NEW LINE
print_r( $Nodes->createQemu($firstNode, $create) ); // NEW LINE