launchdarkly/server-sdk
LaunchDarkly server-side SDK for PHP lets you evaluate feature flags, target users, and manage segments directly in your PHP applications, with streaming updates, polling, and local caching for fast, reliable flag delivery.
What it is. The official LaunchDarkly server-side SDK for PHP: a vendor-maintained client that evaluates feature flags locally, caches flag state, and streams/polls configuration from LaunchDarkly's service or a Relay Proxy. It is the sanctioned integration path for PHP, not a community wrapper.
Architecture fit. Good for Laravel's service-container model — the SDK is a natural singleton (LDClient) resolved once per process, with an LDUser/context object built per request. The friction is lifecycle, not API design: PHP-FPM tears down the process at request end, so a naive binding would construct a client, open a streaming connection, evaluate a flag, and discard it on every request. That is architecturally wrong and will produce latency spikes and connection churn. The package fits well only under one of three deployment shapes:
Integration feasibility. High. Composer install, one service provider, one config file. The public surface is small — client init, variation()/variationDetail(), identify(), flush(), track(). Everything else (targeting rules, segments, prerequisites, experiments) is configured in the LaunchDarkly UI, not in code, so the PHP footprint stays thin. No schema, no migrations, no database coupling.
Technical risk.
NOASSERTION means GitHub's detector failed, not that the license is unusual — LaunchDarkly SDKs are typically Apache-2.0. Still, legal must confirm before this becomes a dependency in a distributed or client-facing artifact.curl; without it, the SDK falls back to slower, blocking file-based event publishing. Verify the target runtime image (Alpine, distroless, minimal FPM images) has the required extensions.Key questions for the vendor/team.
Stack fit. Laravel-native. Register the client as a singleton in a service provider, expose it behind a thin FeatureFlags interface rather than injecting LDClient directly into controllers and jobs. Publish a config/launchdarkly.php fed by environment variables (LAUNCHDARKLY_SDK_KEY, mode, relay URL, cache backend). Provide a Blade directive and a validation rule or middleware if flags gate routes.
Migration path. Do not rip out the current mechanism first. Sequence:
FeatureFlags::bool(string $key, Context $ctx, bool $default) before any product code depends on the vendor. This is the single highest-value step — it makes a future vendor swap a one-class change and keeps the SDK out of domain logic.Compatibility. Confirm PHP and Laravel version support against the project's actual runtime, not the latest. Verify curl and, if using the Redis store, the Redis extension and a Redis instance reachable from every web and worker node. Check that the SDK plays correctly with Octane's worker reuse — singletons that hold state across requests need explicit reset or per-request context construction.
Sequencing dependencies. Relay Proxy infrastructure and network policy must land before the SDK is enabled in streaming mode. Secret distribution for the SDK key must land before any environment goes live. Observability (flag evaluation logs, SDK connection health) should land in the same sprint as the first production flag — otherwise the first incident is undiagnosable.
Maintenance. Low-to-moderate. The vendor ships the code and the security patches; the team owns version pinning, the Relay Proxy deployment, and flag lifecycle. The real maintenance cost is flag debt — flags are cheap to create and expensive to remove. Budget for a recurring audit and a hard rule that a flag that has been at 100% for N weeks gets deleted. Renovate/Dependabot on the SDK and relay image, with a defined patch SLA.
Support. Two layers. Vendor support (LaunchDarkly's plans) covers the service and SDK defects; it does not cover "your context object is malformed" or "your relay is misconfigured" — that is internal on-call. Given the small public footprint, expect to debug more from SDK source and vendor docs than from community answers. Designate one engineer as the internal owner; a flagging system with no owner decays into unmaintained config sprawl.
Scaling. Two dimensions:
Failure modes to instrument and plan for:
track() and evaluation events buffer in memory and flush periodically. High-volume PHP with short-lived processes can lose events on abrupt termination. Call flush() explicitly at request end (terminate() middleware) or on queue job completion; accept that analytics events are best-effort and never make business logic depend on them.curl degrades event delivery silently. Pin and test the runtime image.Ramp-up. Low for the mechanics: an engineer can ship a boolean kill switch in under a day. Moderate for correctness: context design (consistent user keys across web, queue, and CLI; which attributes are safe to send), targeting semantics, and default-value discipline are where teams get burned. Plan a half-day internal walkthrough covering context construction, default values, the Relay Proxy topology, and the flag-removal policy. Include a runbook for "flags are evaluating incorrectly" and "LaunchDarkly is down."
Verdict. Technically sound and the correct choice if the organization is committing to LaunchDarkly; the SDK is thin, well-scoped, and the vendor carries the maintenance. Adoption risk is not in the package — it is in the operational shape (relay infrastructure, PHP process lifecycle), in flag governance, and in the licensing and ecosystem signals that remain unverified. Clear those four items before the first production flag.
How can I help you explore Laravel packages today?