mtxserv/vmware-api

PHP library for interacting with the VMware Rest API.

v1.0.1 2022-07-12 04:32 UTC

This package is auto-updated.

Last update: 2024-04-12 08:08:22 UTC


README

Latest Stable Version

vSphere Api is a modern PHP library based on Guzzle for VMware Rest API.

Dependencies

Installation

Installation of VMware Rest Api is only officially supported using Composer:

composer require mtxserv/vmware-api

Example

<?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());
}