Skip to content

Commit

Permalink
PHP 8 and other things. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Feb 11, 2024
1 parent 7aaf046 commit 5589fa0
Show file tree
Hide file tree
Showing 105 changed files with 932 additions and 585 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ on:

env:
CONSUL_HTTP_ADDR: "127.0.0.1:8500"
CONSUL_VERSION: '1.16.1'
CONSUL_VERSION: '1.17.2'

jobs:
tests:
runs-on: ubuntu-22.04
strategy:
matrix:
php-version: ["7.4", "8.0", "8.1", "8.2"]
php-version: ["8.0", "8.1", "8.2"]

name: Tests - PHP ${{ matrix.php-version }}
steps:
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@

PHP client for the [Consul HTTP API](https://www.consul.io/docs/agent/http.html)

This library is loosely based upon the [official GO client](https://github.com/hashicorp/consul/tree/master/api).
This library is loosely based upon the [official GO client](https://github.com/hashicorp/consul/tree/main/api).

## Version Compatibility

|PHPConsulAPI Version|Consul Version|
|---|---|
|0.3.x|0.6.4|
|0.6.x|0.7-0.8|
|v1.x|0.9-current|
|dev-master|current|
| 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.
Expand All @@ -27,16 +28,16 @@ Require Entry:
```json
{
"require": {
"dcarbone/php-consul-api": "^v1.0"
"dcarbone/php-consul-api": "^v2.0"
}
}
```

## Configuration

First, construct a [Config](./src/Config.php). This class is modeled quite closely after the
[Config Struct](https://github.com/hashicorp/consul/blob/v1.9.3/api/api.go#L280) present in the
[Consul API Subpackage](https://github.com/hashicorp/consul/blob/v1.9.3/api).
[Config Struct](https://github.com/hashicorp/consul/blob/7736539db5305d267b2fd4faa6e86590ca20e556/api/api.go#L339) present in the
[Consul API Subpackage](https://github.com/hashicorp/consul/tree/v1.17.2/api).

### Default Configuration

Expand Down Expand Up @@ -73,7 +74,7 @@ $config = new \DCarbone\PHPConsulAPI\Config([
#### 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](./src/Config.php#L559) for that list, and see [here](./src/Consul.php#L40) for
configuration properties. See [here](./src/Config.php) for that list, and see [here](./src/Consul.php) for
a list of the env var names.

For more advanced client configuration, such as proxy configuration, you must construct your own GuzzleHttp client
Expand All @@ -100,15 +101,16 @@ Next, construct a [Consul](./src/Consul.php) object:
$consul = new \DCarbone\PHPConsulAPI\Consul($config);
```

*NOTE*: If you do not create your own config object, [Consul](./src/Consul.php#L171) will create it's own
using [Config::newDefaultConfig()](./src/Config.php#L253) and attempt to locate a suitable HTTP Client.
*NOTE*: If you do not create your own config object, [Consul](./src/Consul.php) will create it's own
using [Config::newDefaultConfig()](./src/Config.php) and attempt to locate a suitable HTTP Client.

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

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

var_dump($kvResp->Value);
```
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"php-consul-api"
],
"require": {
"php": "7.4.* || 8.*",
"php": "8.*",
"ext-json": "*",
"dcarbone/gotime": "v0.4.* || v0.5.*",
"dcarbone/gotime": "v0.5.*",
"dcarbone/gohttp": "v0.3.*",
"guzzlehttp/guzzle": "^7.4",
"guzzlehttp/psr7": "^2.4"
Expand Down
Loading

0 comments on commit 5589fa0

Please sign in to comment.