1. Go to this page and download the library: Download dcarbone/php-consul-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/ */
$config = new \DCarbone\PHPConsulAPI\Config([
'HttpClient' => $client, // [ // [optional] defaults to "http"
'Datacenter' => 'name of datacenter', // [optional]
'HttpAuth' => 'user:pass', // [optional]
'WaitTime' => '0s', // [optional] amount of time to wait on certain blockable endpoints. go time duration string format.
'Token' => 'auth token', // [optional] default auth token to use
'TokenFile' => 'file with auth token', // [optional] file containing auth token string
'InsecureSkipVerify' => false, // [optional] if set to true, ignores all SSL validation
'CAFile' => '', // [optional] path to ca cert file, see http://docs.guzzlephp.org/en/latest/request-options.html#verify
'CertFile' => '', // [optional] path to client public key. if set,
$proxyClient = new \GuzzleHttp\Client(['proxy' => 'whatever proxy you want']]);
$config = new \DCarbone\PHPConsulAPI\Config([
'HttpClient' => $proxyClient,
'Address' => 'address of server',
]);
$consul = new \DCarbone\PHPConsulAPI\Consul($config);