2017 © Pedro Peláez
 

library php-consul-api

PHP client for the Consul HTTP API

image

dcarbone/php-consul-api

PHP client for the Consul HTTP API

  • Tuesday, June 19, 2018
  • by dcarbone
  • Repository
  • 3 Watchers
  • 36 Stars
  • 10,644 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 42 Versions
  • 28 % Grown

The README.md

php-consul-api

Tests, (*1)

PHP client for the Consul HTTP API, (*2)

This library is loosely based upon the official GO client., (*3)

Version Compatibility

PHPConsulAPI Version Consul Version
0.3.x 0.6.4
0.6.x 0.7-0.8
v1.x 0.9-current
v2.x 0.9-current
dev-master current

Newer versions of the api lib will probably work in a limited capacity with older versions of Consul, but no guarantee is made and backwards compatibility issues will not be addressed., (*4)

Composer

This lib is designed to be used with Composer, (*5)

Require Entry:, (*6)

{
    "require": {
        "dcarbone/php-consul-api": "^v2.0"
    }
}

Configuration

First, construct a Config. This class is modeled quite closely after the Config Struct present in the Consul API Subpackage., (*7)

Default Configuration

If you have defined some of the Consul Environment Variables on your hosts then it would probably be easiest to simply execute the following:, (*8)

$config = \DCarbone\PHPConsulAPI\Config::newDefaultConfig();

Advanced Configuration

You may alternatively define values yourself:, (*9)

$config = new \DCarbone\PHPConsulAPI\Config([
    'HttpClient' => $client,            // [required] Client conforming to GuzzleHttp\ClientInterface
    'Address' => 'address of server',   // [required]

    'Scheme' => 'http or https',            // [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, requires KeyFile also be set
    'KeyFile' => '',                        // [optional] path to client private key.  if set, requires CertFile also be set
    'JSONEncodeOpts'=> 0,                   // [optional] php json encode opt value to use when serializing requests
]);

Configuration Note:

By default, this client will attempt to locate a series of environment variables to describe much of the above configuration properties. See here for that list, and see here for a list of the env var names., (*10)

For more advanced client configuration, such as proxy configuration, you must construct your own GuzzleHttp client prior to constructing a PHPConsulAPI Config object., (*11)

As an example:, (*12)

$proxyClient = new \GuzzleHttp\Client(['proxy' => 'whatever proxy you want']]);
$config = new \DCarbone\PHPConsulAPI\Config([
    'HttpClient' => $proxyClient,
    'Address' => 'address of server',
]);

When constructing your client, if you are using the GuzzleHttp\Client object directly or derivative thereof, you may pass any option listed in the Guzzle Request Options., (*13)

Consul

Next, construct a Consul object:, (*14)

$consul = new \DCarbone\PHPConsulAPI\Consul($config);

NOTE: If you do not create your own config object, Consul will create it's own using Config::newDefaultConfig() and attempt to locate a suitable HTTP Client., (*15)

Once constructed, you interact with each Consul API via it's corresponding Client class:, (*16)

$kvResp = $consul->KV->Keys();
if (null !== $kvResp->Err) {
    die($kvResp->Err);
}

var_dump($kvResp->Value);

...as an example., (*17)

Current Clients

More will be added as time goes on!, (*18)

Tests

The testing suite is still in it's infancy, however it is being tested directly against an actual Consul agent. They will be back-filled as time allows. Future plans are to set up a simple cluster to provide a more real-world testing scenario., (*19)

The Versions

19/06 2018

dev-master

9999999-dev https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api php-consul-api

15/05 2018

0.6.x-dev

0.6.9999999.9999999-dev https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

consul consul-api

15/05 2018

0.6.3

0.6.3.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

consul consul-api

14/05 2018

0.6.2.1

0.6.2.1 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

consul consul-api

14/05 2018

0.6.2

0.6.2.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

consul consul-api

07/05 2018

dev-feature/better-tests

dev-feature/better-tests https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

consul consul-api php-consul-api

07/07 2017

0.6.1.1

0.6.1.1 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

consul consul-api

07/06 2017

0.6.1

0.6.1.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

consul consul-api

05/06 2017

0.6.0

0.6.0.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

consul consul-api

21/05 2017

0.5.2

0.5.2.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

consul consul-api

10/05 2017

0.5.1

0.5.1.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

10/05 2017

dev-feature/better-guzzle-integration

dev-feature/better-guzzle-integration https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

09/05 2017

0.5.0

0.5.0.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

09/05 2017

dev-feature/just-use-guzzle

dev-feature/just-use-guzzle https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

19/04 2017

0.4.5

0.4.5.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

19/04 2017

0.4.4.1

0.4.4.1 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

10/04 2017

0.4.4

0.4.4.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

05/04 2017

0.4.3

0.4.3.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

30/03 2017

0.4.2

0.4.2.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

28/03 2017

0.4.1

0.4.1.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

05/01 2017

0.4.0

0.4.0.0 https://github.com/dcarbone/php-consul-api

PHP client for the Consul HTTP API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

08/10 2016

0.4.x-dev

0.4.9999999.9999999-dev https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Daniel Carbone

psr-7 consul consul-api

04/10 2016

dev-PSR-3

dev-PSR-3 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

09/09 2016

0.3.10

0.3.10.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

03/08 2016

0.3.9

0.3.9.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

03/08 2016

0.3.8

0.3.8.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

22/07 2016

0.3.7

0.3.7.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

22/07 2016

0.3.6

0.3.6.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

22/07 2016

0.3.5

0.3.5.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

22/07 2016

0.3.4

0.3.4.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

21/07 2016

0.3.3

0.3.3.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

21/07 2016

0.3.2

0.3.2.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

21/07 2016

0.3.1

0.3.1.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

21/07 2016

dev-semaphore

dev-semaphore https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

21/07 2016

0.3.0

0.3.0.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

21/07 2016

0.2.4

0.2.4.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

21/07 2016

0.2.3

0.2.3.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

18/07 2016

0.2.2

0.2.2.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

15/07 2016

0.2.1

0.2.1.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

14/07 2016

0.2.0

0.2.0.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

12/07 2016

0.1.0

0.1.0.0 https://github.com/dcarbone/php-consul-api

PHP client implementation for the Consul API

  Sources   Download

Apache-2.0

The Requires

 

by Daniel Carbone

consul consul-api

01/07 2016

dev-transactions

dev-transactions https://github.com/dcarbone/simple-consul-php

Zero-Dependency PHP Client Library for Consul

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

by Daniel Carbone

consul