Download the PHP package chuckbartowski/proxmox-sdk without Composer
On this page you can find all versions of the php package chuckbartowski/proxmox-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chuckbartowski/proxmox-sdk
More information about chuckbartowski/proxmox-sdk
Files in chuckbartowski/proxmox-sdk
Package proxmox-sdk
Short Description PHP SDK for the Proxmox VE API with typed clients, high-level modules and task helpers
License MIT
Informations about the package proxmox-sdk
Framework-agnostic core — usable from any PHP project, script, or worker — with an optional bundle for first-class Symfony integration. Authenticated with API tokens or ticket/cookie credentials, typed exceptions, async task helpers, and a comment-free, strictly typed codebase (PHP 8.2+, declare(strict_types=1) everywhere).
Table of Contents
- Features
- Requirements
- Installation
- Quick Start (plain PHP)
- Symfony Integration (optional)
- Architecture
- Authentication
- Asynchronous Tasks (UPID)
- API Reference
- Nodes
- QEMU virtual machines
- LXC containers
- Cluster
- Storage
- Backups
- Network
- Access control
- Responses
- Error Handling
- Testing
- Security Notes
- WHMCS module
- License
Features
- Wide API coverage: nodes, QEMU VMs, LXC containers, cluster, storage, backup jobs, vzdump, networking, users/tokens/ACLs.
- Both auth modes: API tokens (recommended, stateless) and ticket/cookie login with automatic re-login on expiry and CSRF handling for write requests.
- Task-aware: Proxmox returns a UPID for every asynchronous operation — the SDK detects them (
$response->upid()) and can block until completion (waitForTask()), failing loudly when the task itself failed. - QEMU and LXC share one polished interface: identical lifecycle methods (start, stop, clone, migrate, snapshots, resize…) implemented once, specialized where the APIs differ.
- Framework-agnostic: one plain facade (
Proxmox) you can instantiate anywhere; the only hard dependency issymfony/http-client, a standalone component that works in any PHP project. - A single normalized response object (
ApiResponse) that unwraps Proxmox'sdataenvelope and flattens field-level validation errors. - Typed exception hierarchy under one marker interface, so you can catch narrowly or broadly.
- Nothing is sealed off: the client's
get/post/put/deleteaccept any path, so an endpoint not wrapped by a module is one call away. - Optional Symfony bundle with semantic configuration and autowirable services.
- Fully unit-tested against
MockHttpClient(no network required).
Requirements
| Dependency | Version |
|---|---|
| PHP | >= 8.2 |
| Proxmox VE | 7.x or 8.x (API tokens require 6.2+) |
| Symfony | 6.4 LTS or 7.x — optional, only for the bundle integration |
Installation
The package is published on Packagist:
Quick Start (plain PHP)
No framework required — build the client and go:
Client constructor signature:
Symfony Integration (optional)
Register the bundle:
Then create config/packages/proxmox_sdk.yaml:
Configuration reference
| Key | Type | Default | Description |
|---|---|---|---|
host |
string | required | Proxmox VE hostname (no scheme, no port) |
token_id |
string | '' |
Full token id user@realm!tokenname (preferred) |
token_secret |
string | '' |
Token secret UUID |
username / password |
string | '' |
Ticket auth pair, used when no token is configured |
realm |
string | pam |
Realm appended to username when it has no @ |
port |
int | 8006 |
API TLS port |
verify_ssl |
bool | true |
TLS peer/host verification (see Security Notes) |
timeout |
float | 30.0 |
Per-request timeout in seconds |
The Proxmox facade is then autowirable in controllers, services, commands, and message handlers. The bundle reuses your application's http_client service when available and falls back to a native client otherwise.
Architecture
Design decisions:
- Facade + lazy modules:
Proxmoxinstantiates each module on first use and caches it. - Modules always validate: every module method calls
ensureSuccess()internally and throwsApiExceptionon failure. To inspect a failed response without an exception, drop down to the client level. - One guest abstraction:
AbstractGuestApiimplements the shared VM/container lifecycle;QemuApiadds what only VMs have (hard reset, guest agent, VNC proxy). - Ticket state is self-healing: on a 401/403 with ticket auth, the client discards the ticket, re-logs once, and retries the request transparently.
Authentication
Two modes, checked in order:
- API token (recommended) — stateless, no CSRF, survives restarts. Create one in Datacenter » Permissions » API Tokens (or via this SDK):
Configure with tokenId: 'automation@pve!sdk' + the secret shown once at creation. Grant the token its own permissions when privsep is enabled — a common pitfall: a privilege-separated token has no permissions until you add ACLs for it.
- Ticket (username/password) — the SDK logs in against
/access/ticket, stores the ticket and CSRF token in memory, sendsPVEAuthCookieon every call andCSRFPreventionTokenon writes, and re-logs automatically when the ticket expires (~2 hours).
Missing credentials throw an AuthenticationException immediately, before any network request.
Asynchronous Tasks (UPID)
Most mutating operations (start, clone, migrate, vzdump, destroy…) return immediately with a task identifier (UPID:node:…) while the work continues server-side:
waitForTask() polls the task status until it stops, returns the final status on success (OK or warnings), and throws an ApiException carrying the real exitstatus when the task failed — so a failed clone never masquerades as a success. taskLog() fetches the task output for diagnostics.
API Reference
Every method returns an Error Handling).
Nodes
$proxmox->nodes()
| Method | Endpoint |
|---|---|
list() |
GET /nodes |
status(string $node) |
GET /nodes/{node}/status |
reboot(string $node) / shutdown(string $node) |
POST /nodes/{node}/status |
version(string $node) |
GET /nodes/{node}/version |
services(string $node) / restartService(string $node, string $service) |
GET/POST /nodes/{node}/services… |
tasks(string $node, array $filters = []) |
GET /nodes/{node}/tasks |
taskStatus(...) / taskLog(...) / stopTask(...) |
GET/DELETE /nodes/{node}/tasks/{upid}… |
waitForTask(string $node, string $upid, float $timeout = 300.0, float $pollInterval = 1.0) |
polling helper |
QEMU virtual machines
$proxmox->qemu() — full VM lifecycle on /nodes/{node}/qemu.
| Method | Notes |
|---|---|
list(node) / create(node, vmid, options) / remove(node, vmid, purge: bool) |
purge: true also removes unreferenced disks and job entries |
config(node, vmid) / updateConfig(node, vmid, options) |
|
currentStatus(node, vmid) |
|
start / stop / shutdown / reboot / reset / suspend / resume |
all return a UPID |
clone(node, vmid, newid, options) |
['full' => 1] for a full clone, template linked clones otherwise |
migrate(node, vmid, target, options) |
['online' => 1] for live migration |
resize(node, vmid, disk, size) |
e.g. ('scsi0', '+10G') |
snapshots / createSnapshot / deleteSnapshot / rollbackSnapshot |
|
agentPing(node, vmid) / agentExec(node, vmid, command) |
QEMU guest agent |
vncProxy(node, vmid) |
websocket-enabled console ticket |
LXC containers
$proxmox->lxc() — the same lifecycle interface as QEMU (minus VM-only operations) on /nodes/{node}/lxc.
Cluster
$proxmox->cluster() — version(), status(), resources(?type) (filter: vm, storage, node, sdn), tasks(), nextId(), options() / setOptions(), haResources(), and resource pools: pools(), pool(poolId), createPool(poolId, ?comment), updatePool(poolId, fields) (add/remove vms/storage members, delete => 1 to remove), deletePool(poolId).
nextId() + create() is the standard provisioning pattern shown in the Quick Start.
Storage
$proxmox->storage() — cluster-wide definitions (list, create, update, remove) and per-node views: nodeStorages(node), status(node, storage), content(node, storage, ?contentType), deleteVolume(...), and downloadUrl(node, storage, url, filename) to pull ISOs/templates straight from a URL (returns a UPID).
Backups
$proxmox->backups() — scheduled job management on /cluster/backup (jobs, createJob, updateJob, deleteJob) and on-demand dumps: run(node, options) (POST /nodes/{node}/vzdump) and defaults(node).
Network
$proxmox->network() — node network interfaces: list, find, create(node, iface, type, options) (types: bridge, bond, vlan, …), update, remove, plus apply(node) to activate pending changes and revert(node) to discard them. Proxmox stages network changes — nothing is live until apply().
Access control
$proxmox->access() — users (users, createUser, updateUser, deleteUser), API tokens (tokens, createToken, deleteToken), groups, roles(), and ACLs: acl(), updateAcl(path, roles, options) (add ['delete' => 1] to revoke), permissions(?path, ?userid).
Responses
All calls return an immutable ApiResponse; the Proxmox data envelope is already unwrapped:
Error Handling
All SDK exceptions implement ProxmoxSdkExceptionInterface, so a single catch covers everything:
| Exception | Thrown when | Extras |
|---|---|---|
ApiException |
The API answered but reported a failure, or an awaited task failed | getErrors(), getStatusCode(), getRaw() |
AuthenticationException |
Credentials are missing, login failed, or 401/403 persisted after re-login | thrown before any request when credentials are empty |
TransportException |
Network error, TLS failure, timeout, or a non-JSON response body | wraps the underlying symfony/http-client exception |
To inspect a failed response without exceptions, use the client directly — client-level methods return the response as-is:
Testing
The suite runs entirely offline against MockHttpClient:
To test your own services, inject a ProxmoxClient built with a mock:
Security Notes
- Secrets (
tokenSecret,password) are passed with#[\SensitiveParameter], so they never appear in stack traces. - Prefer API tokens with privilege separation (
privsep => 1) and grant them only the ACLs they need (PVEVMAdminon/vms, notAdministratoron/). - A fresh Proxmox VE ships with a self-signed certificate. Rather than disabling
verify_ssl, install a proper certificate (ACME is built into Proxmox) — keepverify_ssl: falsestrictly for lab environments. - Keep credentials in
.env.localor your secret vault — never commit them. remove()on guests (especially withpurge: true),deleteVolume()androllbackSnapshot()are irreversible — gate destructive calls behind confirmation flows in your application.
WHMCS module
A ready-to-use WHMCS provisioning module ships in whmcs/modules/servers/proxmoxsdk/. It provisions VPS by cloning a template through this SDK — clone + wait + start on create, suspend/resume, terminate (stop + purge), and reboot.
Install
composer require chuckbartowski/proxmox-sdkin your WHMCS root.- Copy the
proxmoxsdkfolder into<whmcs>/modules/servers/. - Add a server with Type: Proxmox VE (SDK), the PVE hostname, the token id (
user@realm!name) as username, and the token secret in the Access Hash field. - Set the config options: Node, Template VMID, and VMID base (the new VMID is
base + service id, so it is deterministic and collision-free).
| Operation | SDK call |
|---|---|
| Create | qemu()->clone() → nodes()->waitForTask() → qemu()->start() |
| Suspend / Unsuspend | qemu()->suspend() / resume() |
| Terminate | qemu()->stop() → remove(purge: true) |
| Reboot | qemu()->reboot() |
License
MIT
All versions of proxmox-sdk with dependencies
symfony/http-client Version ^6.4|^7.0
symfony/http-client-contracts Version ^3.0