承接 corsinvest/cv4pve-api-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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)

License Packagist Version Packagist Downloads PHP Version

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

API Reference

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 corsinvest/cv4pve-api-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.36M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 82
  • 点击次数: 26
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 81
  • Watchers: 5
  • Forks: 29
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-09