4
4
5
5
PHP client for the [ Consul HTTP API] ( https://www.consul.io/docs/agent/http.html )
6
6
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 ) .
8
8
9
9
## Version Compatibility
10
10
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 |
17
18
18
19
Newer versions of the api lib will probably work in a limited capacity with older versions of Consul, but no guarantee
19
20
is made and backwards compatibility issues will not be addressed.
@@ -27,16 +28,16 @@ Require Entry:
27
28
``` json
28
29
{
29
30
"require" : {
30
- "dcarbone/php-consul-api" : " ^v1 .0"
31
+ "dcarbone/php-consul-api" : " ^v2 .0"
31
32
}
32
33
}
33
34
```
34
35
35
36
## Configuration
36
37
37
38
First, 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 ) .
40
41
41
42
### Default Configuration
42
43
@@ -73,7 +74,7 @@ $config = new \DCarbone\PHPConsulAPI\Config([
73
74
#### Configuration Note:
74
75
75
76
By 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
77
78
a list of the env var names.
78
79
79
80
For 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:
100
101
$consul = new \DCarbone\PHPConsulAPI\Consul($config);
101
102
```
102
103
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.
105
106
106
107
Once constructed, you interact with each Consul API via it's corresponding Client class:
107
108
108
109
``` php
109
110
$kvResp = $consul->KV->Keys();
110
- if (null !== $kvResp->Err)
111
+ if (null !== $kvResp->Err) {
111
112
die($kvResp->Err);
113
+ }
112
114
113
115
var_dump($kvResp->Value);
114
116
```
0 commit comments