sensiolabs/consul-php-sdk
A thin PHP wrapper around the Consul HTTP API, covering agent, catalog, health, kv, session and txn services. Methods return a ConsulResponse and throw exceptions on 4xx/5xx errors, with handy lock and semaphore helpers for distributed coordination.
LockHandler, MultiLockHandler, MultiSemaphore) turn "make sure only one worker runs this job" or "cap concurrent calls to a third-party API" from a design project into a library call. Frame the decision explicitly as build vs. buy for coordination primitives: custom DB/Redis locking vs. Consul sessions via this SDK.KV plus the newly whitelisted blocking queries and consistency modes enables push-style config propagation instead of polling — a lever for zero-downtime deploys, per-tenant config, and kill switches without redeploying PHP-FPM.Agent / Catalog / Health cover registration, inventory, and health-driven routing. Relevant if you are splitting a monolith or adding a second region (dc option now accepted on non-local endpoints).Snapshot (backup/DR runbooks), Operator (cluster admin), ACL (programmatic policy management), Event (deploy coordination) — v5.4.0 means internal admin tooling no longer needs a Go sidecar. If your platform team was going to write those scripts anyway, this retires that work.sensiolabs/consul-php-sdk → friendsofphp/consul-php-sdk (v5.0.0, namespace change to Consul\). If any team, doc, or Composer constraint references the old name, that is a small but real ticketed migration — worth resolving before a roadmap commitment rather than during it.dc + Peering.Adopt if:
symfony/http-client 6.4+ (v5.4.0 hard gate; psr/log 2.x/3.x). Confirm the Laravel version in use is compatible with that HTTP client line.Consul\ClientInterface yourself. That is fine, and cheap, if you know it up front.CONSUL_HTTP_TOKEN, blocking queries, dc, multi-valued options like ['tag' => ['v1','primary']], typed 4xx/5xx exceptions via ClientException/ServerException.Look elsewhere if:
Connect coverage is new in 5.4.0; validate the exact endpoints in a spike before putting mTLS intentions on a delivery date.For executives. This is a free, MIT-licensed, small PHP library that lets our PHP services participate directly in Consul — service discovery, dynamic configuration, and distributed locks — instead of us commissioning a bespoke client. It converts a multi-sprint build into a wiring task and is maintained under FriendsOfPHP with a disciplined changelog and a modernized codebase. Two things to be clear about: the library is cheap, but the platform it talks to (Consul) carries the real operating cost, so this is only a good deal if Consul is already part of our infrastructure or roadmap; and it is a small-community project, so we should approve it with a named owner and a fork contingency, not as a set-and-forget dependency.
For engineering. Thin wrapper over the Consul CE HTTP API with a uniform $service->method($required, $options) convention, a ConsulResponse wrapper, and typed ClientException / ServerException for 4xx/5xx. v5.4.0 covers the whole CE API — Agent, Catalog, Health, KV, Session, Txn, plus ACL, Config, Connect, Coordinate, DiscoveryChain, Event, Operator, Peering, PreparedQuery, Snapshot, Status — and whitelists blocking queries, consistency modes, filtering, and dc. Requirements are the decision point: PHP ≥ 8.2, symfony/http-client ≥ 6.4, psr/log 2.x/3.x. In Laravel it is not auto-wired: bind Consul\ClientInterface in a service provider, add a config/consul.php reading CONSUL_HTTP_TOKEN, and inject the service classes where needed. Before committing, run a short spike on the three things that actually bite: lock and session behaviour under clock skew and session TTL, blocking-query timeouts under PHP-FPM worker limits, and token delivery via environment versus cached config.
How can I help you explore Laravel packages today?