PHP code example of mtxserv / vmware-api
1. Go to this page and download the library: Download mtxserv/vmware-api library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mtxserv / vmware-api example snippets
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());
}