Skip to content
Daniel Carbone edited this page Nov 6, 2026 · 3 revisions

php-consul-api

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"

Guides

Clients

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.

Clone this wiki locally