Repository navigation
ConfigEntry
Daniel Carbone edited this page Nov 6, 2026
·
1 revision
$consul->ConfigEntry wraps Consul's Config API for
service-mesh configuration entries (service-defaults, proxy-defaults, service-router, and so on).
use DCarbone\PHPConsulAPI\ConfigEntry\ServiceConfigEntry;
use DCarbone\PHPConsulAPI\Consul;
[$ok, $wm, $err] = $consul->ConfigEntry->Set(entry: new ServiceConfigEntry(
Kind: Consul::ServiceDefaults,
Name: 'web',
Protocol: 'http',
));
[$entry, $qm, $err] = $consul->ConfigEntry->Get(kind: Consul::ServiceDefaults, name: 'web');
// $entry is a ServiceConfigEntry
echo $entry->Protocol;
[$entries, $qm, $err] = $consul->ConfigEntry->List(kind: Consul::ServiceDefaults);
[$wm, $err] = $consul->ConfigEntry->Delete(kind: Consul::ServiceDefaults, name: 'web');Get and List decode each entry into the concrete class for its Kind. Unknown kinds become
GenericConfigEntry. The kind→class table is on the Models page.
[$entry] = $consul->ConfigEntry->Get(kind: Consul::ServiceDefaults, name: 'web');
$entry->setProtocol(Protocol: 'grpc');
[$ok, $wm, $err] = $consul->ConfigEntry->CAS(entry: $entry, index: $entry->getModifyIndex());
[$ok, $wm, $err] = $consul->ConfigEntry->DeleteCAS(kind: Consul::ServiceDefaults, name: 'web', index: $entry->getModifyIndex());$ok is false (with no error) when the index doesn't match. Consul also reports true for a write that changes
nothing, even with a stale index. The index argument accepts int, numeric string or BigInteger (see Big Integers).