{"id":13521545,"url":"https://github.com/Corsinvest/cv4pve-api-php","last_synced_at":"2025-03-31T20:31:51.734Z","repository":{"id":54304349,"uuid":"103121042","full_name":"Corsinvest/cv4pve-api-php","owner":"Corsinvest","description":"Proxmox VE Client API for PHP","archived":false,"fork":false,"pushed_at":"2024-04-02T08:42:33.000Z","size":509,"stargazers_count":58,"open_issues_count":3,"forks_count":23,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-02T09:57:29.603Z","etag":null,"topics":["api","api-client","api-gateway","api-rest","cluster","enterprise","eve2pve-api-php","lxc","php","php-library","proxmox","proxmox-apis","proxmox-cluster","proxmox-ve","proxmoxve","pve","qemu"],"latest_commit_sha":null,"homepage":"https://www.corsinvest.it/cv4pve","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Corsinvest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-09-11T10:12:48.000Z","updated_at":"2024-04-15T10:34:41.940Z","dependencies_parsed_at":"2024-02-28T09:45:13.206Z","dependency_job_id":"326c209c-e1e2-420e-bc51-43c500e5e746","html_url":"https://github.com/Corsinvest/cv4pve-api-php","commit_stats":{"total_commits":45,"total_committers":4,"mean_commits":11.25,"dds":0.4444444444444444,"last_synced_commit":"eb019588cb956b018e765a2dd50b2e4170780412"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corsinvest%2Fcv4pve-api-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corsinvest%2Fcv4pve-api-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corsinvest%2Fcv4pve-api-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Corsinvest%2Fcv4pve-api-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Corsinvest","download_url":"https://codeload.github.com/Corsinvest/cv4pve-api-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246385415,"owners_count":20768672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","api-gateway","api-rest","cluster","enterprise","eve2pve-api-php","lxc","php","php-library","proxmox","proxmox-apis","proxmox-cluster","proxmox-ve","proxmoxve","pve","qemu"],"created_at":"2024-08-01T06:00:35.763Z","updated_at":"2025-03-31T20:31:51.704Z","avatar_url":"https://github.com/Corsinvest.png","language":"PHP","funding_links":[],"categories":["🔧 API \u0026 SDKs"],"sub_categories":["💻 Language-Specific Libraries"],"readme":"# cv4pve-api-php\n\n[![License](https://img.shields.io/github/license/Corsinvest/cv4pve-api-php.svg)](LICENSE) [![Packagist Version](https://img.shields.io/packagist/v/corsinvest/cv4pve-api-php.svg)](https://packagist.org/packages/Corsinvest/cv4pve-api-php) ![Packagist Downloads (custom server)](https://img.shields.io/packagist/dt/corsinvest/cv4pve-api-php)\n\nProxmox VE Client API PHP\n\n[Proxmox VE Api](https://pve.proxmox.com/pve-docs/api-viewer/)\n\n```text\n   ______                _                      __\n  / ____/___  __________(_)___ _   _____  _____/ /_\n / /   / __ \\/ ___/ ___/ / __ \\ | / / _ \\/ ___/ __/\n/ /___/ /_/ / /  (__  ) / / / / |/ /  __(__  ) /_\n\\____/\\____/_/  /____/_/_/ /_/|___/\\___/____/\\__/\n\nCorsinvest for Proxmox VE Api Client  (Made in Italy)\n```\n\n## Copyright and License\n\nCopyright: Corsinvest Srl\nFor licensing details please visit [LICENSE](LICENSE)\n\n## Commercial Support\n\nThis software is part of a suite of tools called cv4pve-tools. If you want commercial support, visit the [site](https://www.corsinvest.it/cv4pve)\n\n## General\n\nThe client is generated from a JSON Api on Proxmox VE.\n\nThis PHP 5.4+ library allows you to interact with your Proxmox server via API.\nThe client is generated from a JSON Api on Proxmox VE.\n\n## Result\n\nThe result is class **Result** and contain methods:\n\n* **getResponse()** returned from Proxmox VE (data,errors,...) Object/Array\n* **responseInError** (bool) : Contains errors from Proxmox VE.\n* **getStatusCode()** (int) : Status code of the HTTP response.\n* **getReasonPhrase()** (string): The reason phrase which typically is sent by servers together with the status code.\n* **isSuccessStatusCode()** (bool) : Gets a value that indicates if the HTTP response was successful.\n* **getError()** (string) : Get error.\n* **getResponseHeaders()** (string) : Gets the raw HTTP headers associated with this response.\n\n## Main features\n\n* Easy to learn\n* No dependency external library only native curl\n* Implementation respect the [Api structure of Proxmox VE](https://pve.proxmox.com/pve-docs/api-viewer/)\n* Method named\n* Set ResponseType json, png\n* Full method generated from documentation\n* Comment any method and parameters\n* Parameters indexed eg [n] is structured in array index and value\n* Tree structure\n  * $client-\u003egetNodes()-\u003eget(\"pve1\")-\u003egetQemu()-\u003eget(100)-\u003egetSnapshot()-\u003esnapshotList()-\u003egetResponse()-\u003edata\n* Return data proxmox\n* Return result\n  * Request\n  * Response\n  * Status\n* Wait task finish task\n  * waitForTaskToFinish\n  * taskIsRunning\n  * getExitStatusTask\n* Method direct access\n  * get\n  * set\n  * create\n  * delete\n* Login return bool if access\n* Return Result class more information\n* Return object/array data\n  * default object disable from client.setResultIsObject(false)\n* ClientBase lite function\n* Form Proxmox VE 6.2 support Api Token for user\n* Login with One-time password for Two-factor authentication.\n* Set Timeout for the Connection.\n\n## Api token\n\nFrom version 6.2 of Proxmox VE is possible to use [Api token](https://pve.proxmox.com/pve-docs/pveum-plain.html).\nThis feature permit execute Api without using user and password.\nIf using **Privilege Separation** when create api token remember specify in permission.\nFormat `USER@REALM!TOKENID=TOKEN` (Usage example below)\n\n## Installation\n\nRecommended installation is using [Composer], if you do not have [Composer] what are you waiting?\n\nIn the root of your project execute the following:\n\n```sh\ncomposer require Corsinvest/cv4pve-api-php\n```\n\nOr add this to your `composer.json`\n\n## Usage\n\n```php\n\u003c?php\n\n// Require the autoloader\nrequire_once 'vendor/autoload.php';\n\n//if you want use lite version only get/set/create/delete use PveClientBase\n\n$client = new Corsinvest\\ProxmoxVE\\Api\\PveClient(\"192.168.0.24\");\n\n//login check bool\nif($client-\u003elogin('root','password','pam')){\n  //get version from get method\n  var_dump($client-\u003eget('/version')-\u003egetResponse());\n\n  // $client-\u003eput\n  // $client-\u003epost\n  // $client-\u003edelete\n\n  $retPippo=$client-\u003eget(\"/pippo\");\n  echo \"\\n\" . $retPippo-\u003egetStatusCode();\n  echo \"\\n\" . $retPippo-\u003egetReasonPhrase();\n\n  //loop nodes\n  foreach ($client-\u003egetNodes()-\u003eIndex()-\u003egetResponse()-\u003edata as $node) {\n    echo \"\\n\" . $node-\u003eid;\n  }\n\n  //loop vm\n  foreach ($client-\u003egetNodes()-\u003eget(\"pve1\")-\u003egetQemu()-\u003eVmlist()-\u003egetResponse()-\u003edata as $vm) {\n      echo \"\\n\" . $vm-\u003evmid .\" - \" .$vm-\u003ename;\n  }\n\n  //loop snapshots\n  foreach ($client-\u003egetNodes()-\u003eget(\"pve1\")-\u003egetQemu()-\u003eget(100)-\u003egetSnapshot()-\u003esnapshotList()-\u003egetResponse()-\u003edata as $snap) {\n    echo \"\\n\" . $snap-\u003ename;\n  }\n\n  //return object\n  var_dump($client-\u003egetVersion()-\u003eversion()-\u003egetResponse());\n\n  //disable return object\n  $client-\u003esetResultIsObject(false);\n  //return array\n  $retArr = $client-\u003egetVersion()-\u003eversion()-\u003egetResponse();\n  var_dump($retArr);\n  echo \"\\n\" . $retArr['data']['release'];\n\n  //enable return objet\n  $client-\u003esetResultIsObject(true);\n\n  //image rrd\n  $client-\u003esetResponseType('png');\n  echo \"\u003cimg src='{$client-\u003egetNodes()-\u003eget(\"pve1\")-\u003egetRrd()-\u003errd('cpu','day')-\u003egetResponse()}' \\\u003e\";\n\n  //result json result\n  $client-\u003esetResponseType('json');\n  var_dump($client-\u003eget('/version')-\u003egetResponse());\n\n  //set connection timeout (by default no timeout)\n  $client-\u003esetTimeout(2)-\u003eget('/version')-\u003egetResponse();\n}\n\n```\n\nSample output version request:\n\n```php\n//object result\nvar_dump($client-\u003egetVersion()-\u003eVersion()-\u003egetResponse());\n\nobject(stdClass)#9 (1) {\n  [\"data\"]=\u003e\n  object(stdClass)#32 (4) {\n    [\"version\"]=\u003e\n    string(3) \"5.0\"\n    [\"release\"]=\u003e\n    string(2) \"31\"\n    [\"keyboard\"]=\u003e\n    string(2) \"it\"\n    [\"repoid\"]=\u003e\n    string(8) \"27769b1f\"\n  }\n}\n\n//disable return object\n$client-\u003esetResultIsObject(false);\n\n//array result\nvar_dump($client-\u003egetVersion()-\u003eVersion());\n\narray(1) {\n  [\"data\"]=\u003e\n  array(4) {\n    [\"repoid\"]=\u003e\n    string(8) \"2560e073\"\n    [\"release\"]=\u003e\n    string(2) \"32\"\n    [\"version\"]=\u003e\n    string(3) \"5.0\"\n    [\"keyboard\"]=\u003e\n    string(2) \"it\"\n  }\n}\n```\n\nThe parameter indexed end with '[n]' in documentation (method createVM in Qemu parameter ide) require array whit key and value\n\n```php\n[\n  1 =\u003e \"....\",\n  3 =\u003e \"....\",\n]\n```\n\n### Usage with API-token instead username/password\n\n```php\n\u003c?php\n\n// Require the autoloader\nrequire_once 'vendor/autoload.php';\n\n//if you want use lite version only get/set/create/delete use PveClientBase\n\n$client = new Corsinvest\\ProxmoxVE\\Api\\PveClient(\"hostname\", \"8006\");\n$client-\u003esetApiToken(\"root@pam!mytokenname=\u003cTOKEN COMES HERE\u003e\");\necho $client-\u003egetVersion();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCorsinvest%2Fcv4pve-api-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCorsinvest%2Fcv4pve-api-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCorsinvest%2Fcv4pve-api-php/lists"}