corsinvest/cv4pve-api-php
Composer 安装命令:
composer require corsinvest/cv4pve-api-php
包简介
Corsinvest Proxmox VE Client API PHP
README 文档
README
______ _ __
/ ____/___ __________(_)___ _ _____ _____/ /_
/ / / __ \/ ___/ ___/ / __ \ | / / _ \/ ___/ __/
/ /___/ /_/ / / (__ ) / / / / |/ / __(__ ) /_
\____/\____/_/ /____/_/_/ /_/|___/\___/____/\__/
Proxmox VE API Client for PHP (Made in Italy)
Quick Start
Installation
composer require corsinvest/cv4pve-api-php
Basic Usage
<?php require_once 'vendor/autoload.php'; use Corsinvest\ProxmoxVE\Api\PveClient; // Create client instance $client = new PveClient("your-proxmox-host.com"); // Authenticate if ($client->login('root@pam', 'password')) { // Get cluster status $status = $client->getCluster()->status(); echo "Cluster: {$status->getResponse()->data[0]->name}\n"; // List all VMs $vms = $client->getNodes()->get("pve1")->getQemu()->vmlist(); foreach ($vms->getResponse()->data as $vm) { echo "VM {$vm->vmid}: {$vm->name} - {$vm->status}\n"; } }
Key Features
Developer Experience
- Intuitive API Structure - Mirrors Proxmox VE API hierarchy with fluent interface
- Tree-Based Navigation - Natural method chaining matching API paths
- Flexible Response Handling - Choose between object or array response formats
- Comprehensive Documentation - Detailed guides and practical examples
- Easy Integration - Simple Composer installation with minimal dependencies
Core Functionality
- Complete API Coverage - Full implementation of Proxmox VE REST API endpoints
- VM & Container Management - Create, configure, start, stop, and monitor virtual machines and containers
- Cluster Operations - Monitor cluster status, resources, and health
- Storage Management - Handle storage pools, volumes, and content
- Network Configuration - Manage network interfaces and firewall rules
Enterprise Ready
- Multiple Authentication Methods - Username/password, API tokens, and two-factor authentication
- API Token Support - Secure token-based authentication for automation
- SSL Certificate Validation - Configurable certificate verification for production environments
- Task Management - Monitor and wait for long-running async operations
- Timeout Configuration - Customizable connection and request timeouts
Advanced Features
- Result Object Pattern - Structured response handling with status codes and error checking
- Event Callbacks - Hook into API actions for logging and monitoring
- Zero Dependencies - Lightweight design using only native PHP cURL
- PHP 5.5+ Compatible - Wide compatibility with modern and legacy environments
- Cross-Platform - Works on Windows, Linux, and macOS
Documentation
Getting Started
- Authentication - Login methods, API tokens, and security best practices
- Basic Examples - Common operations and usage patterns
- Advanced Usage - Production configurations and enterprise patterns
- Common Issues - Troubleshooting and configuration tips
API Reference
- API Structure - Understanding the tree-based API navigation
- Result Handling - Working with responses and data
- Error Handling - Exception management and error patterns
- Task Management - Monitoring async operations
Examples
VM Management
<?php // Create and configure a new VM with individual parameters (PHP 8.1+) // Using named arguments (PHP 8.0+) for clarity $result = $client->getNodes()->get("pve1")->getQemu()->createVm( vmid: 100, name: 'production-web-server', memory: 4096, cores: 4, net0: 'virtio,bridge=vmbr0', scsi0: 'local-lvm:32', acpi: true, balloon: 0, cpu: 'host', numa: false, hotplug: 'network,disk,cpu,memory', tags: 'production,web', template: false ); if ($result->isSuccessStatusCode()) { echo "VM created successfully!\n"; // Start the VM $startResult = $client->getNodes()->get("pve1")->getQemu()->get(100)->getStatus()->getStart()->vmStart(); if ($startResult->isSuccessStatusCode()) { echo "VM started successfully!\n"; } } else { echo "Error creating VM: " . $result->getError() . "\n"; }
Cluster Monitoring
<?php // Monitor cluster resources $resources = $client->getCluster()->resources(); foreach ($resources->getResponse()->data as $resource) { if ($resource->type === 'vm' && $resource->status === 'running') { $cpuPercent = round($resource->cpu * 100, 2); $memPercent = round(($resource->mem / $resource->maxmem) * 100, 2); echo "VM {$resource->vmid}: CPU {$cpuPercent}%, RAM {$memPercent}%\n"; } }
Automated Backup
<?php // Create backup for multiple VMs $vmids = [100, 101, 102]; $backup = $client->getNodes()->get("pve1")->getVzdump()->create( vmid: implode(',', $vmids), // Comma-separated VM IDs storage: 'backup-storage', // Storage target mode: 'snapshot', // Backup mode compress: 'zstd' // Compression algorithm ); $taskId = $backup->getResponse()->data; echo "Backup started with task: {$taskId}\n";
Support
For professional consulting and enterprise support, visit www.corsinvest.it
Part of cv4pve suite | Made with ❤️ in Italy by Corsinvest
Copyright © Corsinvest Srl
corsinvest/cv4pve-api-php 适用场景与选型建议
corsinvest/cv4pve-api-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.36M 次下载、GitHub Stars 达 81, 最近一次更新时间为 2019 年 07 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「Virtualization」 「cluster」 「Proxmox」 「KVM」 「LXC」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 corsinvest/cv4pve-api-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 corsinvest/cv4pve-api-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 corsinvest/cv4pve-api-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple PHP 7+ Proxmox API client for VE and MG.
PHP Long Running Process Manager Cluster
A Filament-native cards plugin for organizing pages and resources into a card-based navigation hub.
A PSR-7 compatible library for making CRUD API endpoints
A simple PHP 5.5+ Proxmox API client.
A simple PHP 5.5+ Proxmox API client.
统计信息
- 总下载量: 1.36M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 82
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-09