Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Consul Php Sdk Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. This is a thin, framework-agnostic HTTP wrapper, not a Laravel package. Each Consul API surface (Agent, Catalog, Health, KV, Session, Txn, plus ACL, Config, Connect, Operator, Peering, PreparedQuery, Snapshot, Status as of v5.4.0) maps to a PHP service class with a uniform $service->method($required, $options) signature, a ConsulResponse value object, and typed ClientException (4xx) / ServerException (5xx). That is a good fit for a TPM's purposes: the abstraction boundary is honest, so we can wrap it in our own Laravel service provider and facade without the SDK fighting us. It is a poor fit as an application-facing API — there is no caching, retry, circuit breaking, or degradation logic, so every one of those concerns becomes ours.

Identity and provenance risk. The brief says sensiolabs/consul-php-sdk, but the package was renamed to friendsofphp/consul-php-sdk in v5.0.0 (namespace moved from SensioLabs\Consul to Consul). Two consequences: (1) our dependency manifest and SBOM must reference the new name or we will pin an abandoned artifact; (2) an unreserved legacy name is a dependency-confusion surface — confirm with whoever owns our private registry that sensiolabs/* is blocked or explicitly allow-listed. Dependents: 0 and 317 stars are a weak adoption signal, and the listed release date (2026-09-29) is inconsistent with the changelog history — treat the package metadata feed as unreliable and verify against GitHub directly before it enters a build.

Integration feasibility. Moderate, with one real friction point: the SDK requires symfony/http-client (≥6.4 on v5.4), while Laravel ships Guzzle. We would run two HTTP client stacks, two connection pools, and two sets of timeout/telemetry conventions. Acceptable, but it should be a conscious decision, not an accident. Otherwise requirements are cleanly satisfiable: PHP ≥8.2, psr/log 2.x/3.x, no framework coupling, no global state.

Technical risk.

  • Thin wrapper = all resilience is ours. No retries, backoff, circuit breaker, or fallback. Consul becoming slow is indistinguishable from the application becoming slow.
  • Blocking queries vs. PHP-FPM. Blocking queries are the headline capability for push-style config, but they hold a worker open for the query duration. This belongs on queue workers or a dedicated daemon, never a web request.
  • Environment-driven auth vs. Laravel config caching. Reading CONSUL_HTTP_TOKEN from the environment works at bootstrap, but env() outside config/ returns null once php artisan config:cache runs. Token injection must go through a config file backed by a secret manager.
  • No first-party Laravel glue. No service provider, no package discovery, no health-check registration helper, no lifecycle integration. We build and own that shim.
  • Semver hygiene. v5.4.0 is a minor release that raised the floor to PHP 8.2 and Symfony 6.4, i.e. a requirement change in a non-major. Pin exact versions.
  • Historical correctness bugs in the helper layer. Agent::join()/forceLeave() used the wrong HTTP verb until 5.4.0 (silent bootstrap failure), and MultiSemaphore reused metadata across resources (fixed in 5.4.0). Anyone on 5.3 inherits both.

Key questions for the team.

  1. Is Consul a strategic platform commitment, or are we adding it because a service-discovery need is currently unowned? Kubernetes-native discovery or cloud-managed registries may retire this dependency entirely.
  2. Who runs the Consul cluster, and do we need Enterprise (namespaces, admin partitions)? The SDK covers CE only — that boundary is now explicit and must be validated against our tenancy model.
  3. What is our tolerated behaviour when Consul is unavailable — fail open with last-known-good config, or fail closed?
  4. Do we need distributed locks? If so, do we accept the fencing-token gap in LockHandler/MultiLockHandler, or keep Redis/DB locks for anything financially material?
  5. Can platform engineering own a forked adapter indefinitely if upstream stalls?

Integration Approach

Stack fit. Target Laravel 10–12 on PHP 8.2+, with the SDK pinned to v5.4.x. Bind Consul\ClientInterface (introduced v5.1.0) in a container provider rather than instantiating services ad hoc — that single decision buys us test doubles, per-environment configuration, and a future swap point. Expose a narrow internal facade (Discovery::healthy('billing'), Config::get('feature.x')) so application code never imports the vendor namespace; that keeps the vendor surface to one directory and makes an exit cheap.

Migration path.

  1. Spike (1 week). Stand up a dev agent, exercise Agent/Catalog/Health read paths, confirm the token flows correctly under config:cache, and prototype one blocking query on a queue worker.
  2. Adapter package (1 sprint). Internal laravel-consul composer package: config file, service provider, facade, cached catalog lookups, retry/circuit-breaker policy, structured logging, health-check route.
  3. Read path. Replace hardcoded service hostnames and env-var endpoints with Health-filtered Catalog lookups, behind a feature flag with a static-config fallback.
  4. Registration. A scheduled command or deployment hook registers the app instance and TTL health check via Agent; deregistration on shutdown. This is the piece most likely to be underestimated.
  5. Dynamic config. KV reads with blocking queries in a long-running worker pushing into the cache; Config service for environment-scoped values.
  6. Locks/semaphores. Only for idempotency and deploy coordination — deliberately not for anything requiring strict mutual exclusion.
  7. Deferred. Connect/mTLS, PreparedQuery/DiscoveryChain, Peering, Snapshot/Operator/ACL automation — valuable, but Phase 3+ and gated on whether we commit to Consul at all.

Compatibility. Run composer why-not friendsofphp/consul-php-sdk 5.4.* early. The realistic conflicts are other packages pinning symfony/http-client below 6.4 or psr/log 1.x, plus any Laravel version constrained to older Symfony components. Both are resolvable but each is a multi-day conversation with the owning team. Also confirm the SDK's HTTP client does not silently inherit global Guzzle/Symfony defaults from a shared container.

Sequencing. Do not start with Connect. The dependency-name question, the Laravel shim, and the Consul-down degradation policy are the three items that block everything else and none of them are code-heavy. Resolve them before the first production call.

Operational Impact

Maintenance. MIT, active, modernised codebase (readonly classes, PHPUnit 11+, phpstan, php-cs-fixer), and a credible umbrella org — these are genuine maintainability signals to cite in an architecture review. But it is a small-maintainer project with zero dependents on record; bus factor is the real risk. Mitigation: vendor the dependency into our monorepo (Composer path or Satis mirror) so a stalled upstream is a fork, not an incident. Budget roughly 0.1 FTE for the shim and upgrades, plus a quarterly review of upstream releases.

Support. Community-only: GitHub issues, no SLA, no vendor to escalate to. Our support model must be "platform team owns it, upstream is best-effort." That is fine for internal infrastructure glue and disqualifying if this is embedded in a customer-facing SLA without a fork. Establish an internal owner and a documented upgrade cadence before adoption.

Scaling. Every service class ultimately talks HTTP to a Consul agent; connection count, agent locality (sidecar vs. remote), and blocking-query worker count are the three dials. The SDK provides none of them. Specific concerns: no built-in connection reuse policy, blocking queries consuming FPM workers under Octane (where a blocked worker stalls a long-lived process), catalog read amplification if we query per-request instead of caching, and cross-datacenter latency now that dc is accepted everywhere — use local agents and cache aggressively.

Failure modes to design for now.

  • Consul unavailable → ServerException on every call; without a cache-first policy the application fails on a dependency that should be advisory.
  • ACL token expiry/rotation → ClientException (403) surfaces as an application error; needs explicit handling and a rotation runbook using the CONSUL_HTTP_TOKEN/secret-manager path.
  • Session TTL expiry during a critical section → lock silently lost, two workers proceed. Without fencing tokens this is silent data corruption. Keep strict-mutex workloads off this helper.
  • Semaphore metadata leak across resources — latent on ≤5.3; enforces the exact-pin policy.
  • Config-cache token nulling → 403s that appear only in production after config:cache; catch in the spike.
  • Blocking-query timeout ambiguity — a client-side timeout is not the same as a server-side no-change response; treat as unknown and re-read.

Ramp-up. The API is easy to learn — a mid-level PHP developer is productive in a day on KV/Catalog/Health. The domain is not. Sessions, ACL policies, consistency modes, blocking-query indices, and datacenter semantics leak straight through the "thin wrapper" abstraction, so expect 1–2 weeks to competence on the read path and materially longer for locks and ACL automation. The larger cost is not developer ramp-up but operations ramp-up: someone must be able to run, back up (Snapshot), and reason about a Consul cluster. If we have no owner for that, the SDK is not the decision — Consul is, and it should be re-evaluated on its own merits.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
adachsoft/php-code-style