performave / proxmox
此包已被废弃且不再维护。未建议替代包。
Proxmox VE API 客户端
0.5.1
2022-07-22 00:39 UTC
Requires
- php: ^8.0|7.4|^8.1
- ext-json: *
- lib-curl: *
- guzzlehttp/guzzle: *
README
此库已被弃用,转而使用自定义逻辑来调用 Proxmox API。这是因为库设计不佳,难以维护。
Proxmox API
此 PHP 8+ Proxmox 库允许您以面向对象的方式与 Proxmox PVE 服务器和集群交互。
此库是基于另一个库的分支,并且由于在实际项目中使用,因此积极维护。
如果您发现任何错误、错别字或错误,请 提交问题。我会尝试发布热补丁。
入门指南
通过命令行使用 Composer 安装
$ composer require performave/proxmox
示例
从版本 3.1
<?php // Require the autoloader require_once 'vendor/autoload.php'; // Use the library namespace use Proxmox\PVE; // Then simply pass your credentials when creating the API client object. $proxmox = new PVE("hostname", "username", "password", 8006, "pve", false); //Read all nodes print_r($proxmox->nodes()->get()); //Read all lxc print_r($proxmox->nodes()->lxc()->get()); //Read all qemu print_r($proxmox->nodes()->qemu()->get());
针对版本 3.1
警告:从 3.0 版本开始,不再支持数组选项! |
---|
<?php // Require the autoloader require_once 'vendor/autoload.php'; // Use the library namespace use Proxmox\PVE; /** * Connect established (For version 3.0) * * authType and port defaults to 'pam' and '8006' but you can specify them like so * * !!! WARNING !!! * This variant is after version 3.0 no longer supported * */ $credentials = [ 'hostname' => '127.0.0.1', 'username' => 'root', 'password' => 'example', 'authType' => 'pam', 'port' => '8006', ]; // Then simply pass your credentials when creating the API client object. $proxmox = new PVE($credentials); //Read all nodes print_r($proxmox->nodes()->get()); //Read all lxc print_r($proxmox->nodes()->lxc()->get()); //Read all qemu print_r($proxmox->nodes()->qemu()->get());