Skip to content

V3 Work #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cc0831e
working on v3
dcarbone Apr 11, 2025
480e352
bit of readme update
dcarbone Apr 11, 2025
50e6268
readme
dcarbone Apr 11, 2025
c1b7373
allowing old map-style construction
dcarbone Apr 11, 2025
97dfca7
small readme, may change...
dcarbone Apr 11, 2025
1a89930
lets be correct.
dcarbone Apr 11, 2025
9519d43
reduce pointless line changes in PR.
dcarbone Apr 11, 2025
7a4f1c8
well that was dumb.
dcarbone Apr 11, 2025
f847aee
removing trash, updating some base classes
dcarbone Apr 11, 2025
838eda5
it can't be null
dcarbone Apr 11, 2025
65e8e85
Fine.
dcarbone Apr 11, 2025
0301bec
grammar
dcarbone Apr 11, 2025
99f810d
dangit, the boy is right.
dcarbone Apr 11, 2025
7b5bb04
thanx fren.
dcarbone Apr 11, 2025
279b0fb
allow default in $data, starting work on Agent
dcarbone Apr 11, 2025
13784d3
oops
dcarbone Apr 11, 2025
f53867c
lots of little work, long ways to go.
dcarbone Apr 13, 2025
6e11429
lots more work, need to go back and fix some things.
dcarbone Apr 13, 2025
cbec949
missed one
dcarbone Apr 13, 2025
af356ca
maybe agent done?
dcarbone Apr 14, 2025
f047f4c
i dunno, sure.
dcarbone Apr 14, 2025
2554c66
ugh.
dcarbone Apr 14, 2025
4f1a05c
ACL work.
dcarbone Apr 15, 2025
ec161b4
some cleanup
dcarbone Apr 15, 2025
e2f0167
only acl & agent for now
dcarbone Apr 15, 2025
7505b50
smidge test cleanup
dcarbone Apr 15, 2025
ca38b54
who cares.
dcarbone Apr 15, 2025
33a8236
php-cs-fixer fixes, prolly add stan
dcarbone Apr 15, 2025
648bc95
phpstan, going to be a little bit of a rabbit hole...
dcarbone Apr 15, 2025
47c6b15
its late.
dcarbone Apr 15, 2025
aaeba90
gotta fix acl with dev
dcarbone Apr 15, 2025
040ae39
stdclass are a pain to work with, but faster than fussing around with…
dcarbone Apr 16, 2025
2be67f0
objects
dcarbone Apr 16, 2025
5a5cbd8
more werk
dcarbone Apr 16, 2025
6dfbd9b
test fixups
dcarbone Apr 16, 2025
6c437e4
AgentMember fixes
dcarbone Apr 16, 2025
707ce40
bleh...
dcarbone Apr 16, 2025
a170dab
less stupid, but its still stupid.
dcarbone Apr 17, 2025
1394fb5
small cleanup
dcarbone Apr 17, 2025
c68166b
more cleanup
dcarbone Apr 17, 2025
4f289c0
some enums and cleanup
dcarbone Apr 17, 2025
e4077be
starting on catalog...
dcarbone Apr 17, 2025
0f895ac
small thing
dcarbone Apr 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 44 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,27 @@ This library is loosely based upon the [official GO client](https://github.com/h
| 0.6.x | 0.7-0.8 |
| v1.x | 0.9-current |
| v2.x | 0.9-current |
| v3.x | 0.9-current |
| dev-main | 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.

### V3 Breaking Changes

There are a couple breaking changes between v2 and v3:

1. The `FakeMap` class has been removed.
2. The `FakeSlice` class has been removed.
3. The `ReadableDuration` class has been removed.
4. All models now have parameterized constructors.
* For the life of V3 I will continue to support construction from associative arrays, but the parameterized
constructors are the preferred method of construction.
* Construction via associative array will be removed entirely in V4 (whenever I get around to that).
5. All of that `Transcoding` nonsense has been removed.
6. The root `Config` class may no longer be constructed with a map. You must use constructor parameters.
7. All "map" fields are now defined as `\stdClass` objects.

## Composer

This lib is designed to be used with [Composer](https://getcomposer.org)
Expand All @@ -28,7 +44,7 @@ Require Entry:
```json
{
"require": {
"dcarbone/php-consul-api": "^v2.0"
"dcarbone/php-consul-api": "^v3.0"
}
}
```
Expand All @@ -53,22 +69,28 @@ $config = \DCarbone\PHPConsulAPI\Config::newDefaultConfig();
You may alternatively define values yourself:

```php
$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
]);
$config = new \DCarbone\PHPConsulAPI\Config(
// required fields
HttpClient: $client, // [required] Client conforming to GuzzleHttp\ClientInterface
Address: 'address of server', // [required]

// optional fields
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

// php specific options
JSONEncodeOpts: JSON_UNESCAPED_SLASHES,
JSONDecodeMaxDepth: 512,
JSONDecodeOpts: 0,
);
```

#### Configuration Note:
Expand All @@ -83,11 +105,11 @@ prior to constructing a PHPConsulAPI Config object.
As an example:

```php
$proxyClient = new \GuzzleHttp\Client(['proxy' => 'whatever proxy you want']]);
$config = new \DCarbone\PHPConsulAPI\Config([
'HttpClient' => $proxyClient,
'Address' => 'address of server',
]);
$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
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
}
},
"require-dev": {
"phpunit/phpunit": "^10.5 || ^11.0"
"phpunit/phpunit": "^10.5 || ^11.0",
"phpstan/phpstan": "~2.1.11"
},
"autoload-dev": {
"files": [
Expand Down
Loading