Repository navigation
Home
Daniel Carbone edited this page Nov 6, 2026
·
3 revisions
A PHP client for the Consul HTTP API, modeled closely on the official Go client. If you know the Go API, you already know most of this one: the same clients, method names, models, and field names.
use DCarbone\PHPConsulAPI\Consul;
use DCarbone\PHPConsulAPI\KV\KVPair;
$consul = new Consul();
[$wm, $err] = $consul->KV->Put(p: new KVPair(Key: 'hello', Value: 'world'));
[$pair, $qm, $err] = $consul->KV->Get(key: 'hello');
echo $pair->Value; // "world"- Getting Started: installation and your first requests
-
Configuration:
Config, environment variables, TLS, and custom HTTP clients - Responses and Errors: destructuring responses and handling errors
- Query and Write Options: per-request options, blocking queries, and response metadata
- Models: constructing, reading, and serializing API models
-
Big Integers:
uint64values asBrick\Math\BigInteger - Durations and Time: Go-style durations and timestamps
- Differences from Go: every known divergence from the Go client
- Upgrading: notes on breaking changes between versions
- Development: running tests and static analysis
| Client | Consul API |
|---|---|
| ACL | /v1/acl |
| Agent | /v1/agent |
| Catalog | /v1/catalog |
| ConfigEntry | /v1/config |
| Coordinate | /v1/coordinate |
| Debug | /debug/pprof |
| Event | /v1/event |
| Health | /v1/health |
| KV | /v1/kv |
| Operator | /v1/operator |
| Peering | /v1/peering |
| PreparedQuery | /v1/query |
| Session | /v1/session |
| Status | /v1/status |
| Txn | /v1/txn |
Each client is available on Consul both as a property ($consul->KV) and as a method ($consul->KV()).
Every client page lists each method, what it returns, and how to destructure the response.