mtxserv / vmware-api
用于与 VMware Rest API 交互的 PHP 库。
v1.0.1
2022-07-12 04:32 UTC
Requires
- php: ^7.0|^8.0|^8.1
- guzzlehttp/guzzle: ^7.0
README
vSphere Api 是一个基于 Guzzle 的现代 PHP 库,用于 VMware Rest API。
依赖项
- PHP 7 / 8
- Guzzle: ^7.0
安装
VMware Rest Api 的安装仅官方支持使用 Composer
composer require mtxserv/vmware-api
示例
<?php use VMware\VMwareClient; use GuzzleHttp\Exception\GuzzleException; $client = new VMwareClient([ 'base_uri' => 'https://my-pcc.ovh.com', 'vmware_user' => 'my_user', 'vmware_password' => 'my_password', ]); try { // Get VM list $response = $client->get('/rest/vcenter/vm'); // See: https://developer.vmware.com/apis/vsphere-automation/latest/vcenter/api/vcenter/vm/get/ $json = json_decode($response->getBody()->getContents(), \JSON_THROW_ON_ERROR); var_dump($json); } catch (GuzzleException $e) { var_dump($e->getMessage()); }