44
55PHP client for the [ Consul HTTP API] ( https://www.consul.io/docs/agent/http.html )
66
7- This library is loosely based upon the [ official GO client] ( https://github.com/hashicorp/consul/tree/master /api ) .
7+ This library is loosely based upon the [ official GO client] ( https://github.com/hashicorp/consul/tree/main /api ) .
88
99## Version Compatibility
1010
11- | PHPConsulAPI Version| Consul Version|
12- | ---| ---|
13- | 0.3.x| 0.6.4|
14- | 0.6.x| 0.7-0.8|
15- | v1.x| 0.9-current|
16- | dev-master| current|
11+ | PHPConsulAPI Version | Consul Version |
12+ | ----------------------| ----------------|
13+ | 0.3.x | 0.6.4 |
14+ | 0.6.x | 0.7-0.8 |
15+ | v1.x | 0.9-current |
16+ | v2.x | 0.9-current |
17+ | dev-master | current |
1718
1819Newer versions of the api lib will probably work in a limited capacity with older versions of Consul, but no guarantee
1920is made and backwards compatibility issues will not be addressed.
@@ -27,16 +28,16 @@ Require Entry:
2728``` json
2829{
2930 "require" : {
30- "dcarbone/php-consul-api" : " ^v1 .0"
31+ "dcarbone/php-consul-api" : " ^v2 .0"
3132 }
3233}
3334```
3435
3536## Configuration
3637
3738First, construct a [ Config] ( ./src/Config.php ) . This class is modeled quite closely after the
38- [ Config Struct] ( https://github.com/hashicorp/consul/blob/v1.9.3 /api/api.go#L280 ) present in the
39- [ Consul API Subpackage] ( https://github.com/hashicorp/consul/blob /v1.9.3 /api ) .
39+ [ Config Struct] ( https://github.com/hashicorp/consul/blob/7736539db5305d267b2fd4faa6e86590ca20e556 /api/api.go#L339 ) present in the
40+ [ Consul API Subpackage] ( https://github.com/hashicorp/consul/tree /v1.17.2 /api ) .
4041
4142### Default Configuration
4243
@@ -73,7 +74,7 @@ $config = new \DCarbone\PHPConsulAPI\Config([
7374#### Configuration Note:
7475
7576By default, this client will attempt to locate a series of environment variables to describe much of the above
76- configuration properties. See [ here] ( ./src/Config.php#L559 ) for that list, and see [ here] ( ./src/Consul.php#L40 ) for
77+ configuration properties. See [ here] ( ./src/Config.php ) for that list, and see [ here] ( ./src/Consul.php ) for
7778a list of the env var names.
7879
7980For more advanced client configuration, such as proxy configuration, you must construct your own GuzzleHttp client
@@ -100,15 +101,16 @@ Next, construct a [Consul](./src/Consul.php) object:
100101$consul = new \DCarbone\PHPConsulAPI\Consul($config);
101102```
102103
103- * NOTE* : If you do not create your own config object, [ Consul] ( ./src/Consul.php#L171 ) will create it's own
104- using [ Config::newDefaultConfig()] ( ./src/Config.php#L253 ) and attempt to locate a suitable HTTP Client.
104+ * NOTE* : If you do not create your own config object, [ Consul] ( ./src/Consul.php ) will create it's own
105+ using [ Config::newDefaultConfig()] ( ./src/Config.php ) and attempt to locate a suitable HTTP Client.
105106
106107Once constructed, you interact with each Consul API via it's corresponding Client class:
107108
108109``` php
109110$kvResp = $consul->KV->Keys();
110- if (null !== $kvResp->Err)
111+ if (null !== $kvResp->Err) {
111112 die($kvResp->Err);
113+ }
112114
113115var_dump($kvResp->Value);
114116```
0 commit comments