influxdata/influxdb-client-php
Official reference PHP client library for InfluxDB 2.x (also works with InfluxDB 1.8+). Query and write data, manage buckets and tasks via the 2.x API, add default tags, write over UDP, delete data, and handle proxies and redirects.
Architecture fit. The package is a thin, vendor-maintained SDK: a Client facade over three API surfaces (WriteApi, QueryApi, and a Management API), with transport abstracted behind PSR-7/PSR-17/PSR-18. That is a favorable shape for Laravel — it binds cleanly as a container singleton, has no framework assumptions, and lets us inject Guzzle (already a transitive dependency of Laravel) rather than discovering a client implicitly. It is a data-access client, not a domain library: it should live entirely inside an infrastructure namespace behind our own port.
Integration feasibility. Composer install, one config file, one service provider, one adapter class. No PHP extension requirements, no native build, no daemon. Expected effort for a production-shaped integration: 1–2 days of engineering for binding/config/fake, then the real cost is downstream (Flux authoring, schema/cardinality policy, dashboards). The Management API is where scope creep starts — bucket/org provisioning in application code will collide with IaC.
Technical risk.
WriteApi buffers in-process. Under PHP-FPM that means buffers flush at request end and are lost on OOM/kill; under Octane/queue workers it becomes long-lived shared state, with cross-request leakage and unbounded-buffer risk if not reset per request. This is the single largest operational trap.timeout (default 10s); batched writes can swallow failures unless the error callback is wired. Neither default is acceptable on a user-facing request path.Key questions.
Stack fit. PSR-18 transport plus Laravel's bundled Guzzle means near-zero dependency friction; no compiled extensions, no sidecar required. The SDK's lack of framework coupling is an advantage only if we add the coupling ourselves in one place: config/influxdb.php (url, token, org, bucket, precision, timeout), a InfluxDBServiceProvider registering InfluxDB2\Client as a singleton built from that config, and a single InfluxDbMetricsWriter adapter implementing our own MetricsWriter port. Domain code must never see Point, FluxRecord, or FluxTable — those stay inside the adapter so a future swap (InfluxDB 3 client, Timescale, ClickHouse) is a class replacement rather than a codebase sweep.
Non-negotiable design choices.
timeout (2–3s, not the 10s default), verifySSL true, and a connection pool sized to worker count; do not rely on PSR-18 discovery.close(); never hold a batched WriteApi across requests.ArrayMetricsWriter/NullMetricsWriter fake in the same PR as the adapter so tests don't require a live database.Migration path.
If we are on InfluxDB 1.x today (influxdb-php client), treat this as an auth-and-data-model migration (token/org/bucket, line protocol differences), not a library swap. The 1.8 compatibility API is a bridge for a sprint, not a destination.
Compatibility and sequencing. Pin to a compatible range and read the changelog before each bump; this is a low-release-cadence vendor package, so a quarterly review is sufficient. Sequence the Management API last or not at all — if Terraform owns buckets, exclude it from the adapter. Ensure container images carry CA roots and that proxy/timeout behavior is covered by config, since those three options are Guzzle-dependent and will silently diverge if someone swaps the HTTP client later.
Maintenance. The SDK itself is cheap to maintain: MIT, changelog, tagged releases, vendor-owned. The cost center is our ~200–400 lines of adapter, provider, schema allowlist, and fake — that is the code we own forever and must staff for. Budget one engineer-day per quarter for dependency review plus the changelog, and watch releases for InfluxDB 3.x deprecation signals. Confine Flux strings to a small number of files to keep that future migration tractable.
Support. No commercial SLA comes with an MIT package, and at this adoption level there are no battle-tested Laravel patterns to lean on from the community. Internal runbook, dashboard, and a named on-call owner for the metrics pipeline are mandatory deliverables, not nice-to-haves. Escalation path is the vendor's issue tracker and Slack; set expectations that response times are best-effort unless we buy support.
Scaling. Two independent curves. Application-side: batched writes amortize HTTP overhead, but buffer bytes × concurrent workers is real memory; at high worker counts the arithmetic gets uncomfortable, which again argues for the agent pattern. Database-side: cardinality — not throughput — is the wall. Per-user IDs, request IDs, unbounded URLs, or free-text tags will degrade query performance and can destabilize the instance. Enforce the tag allowlist in code, and size retention, shard duration, and downsampling tasks as a separate capacity exercise with an owner. Also plan Guzzle connection pooling and InfluxDB connection limits together; naive concurrency tuning on the PHP side just relocates the bottleneck.
Failure modes to design against.
precision setting that disagrees with the timestamp unit silently produces points decades off; pin it once in config and test it.Ramp-up. A senior Laravel engineer reaches productive write-path work in a day; competent Flux authoring is closer to two to three weeks and is the real ramp-up cost. Plan for: the one-page ADR (why InfluxDB, direct-write vs agent, 2.x exit assumption), the adapter + fake delivered together, one reference dashboard as a template, and a cardinality policy document. Fund a half-day schema workshop and appoint a single metrics steward — shared ownership of the tag schema is how these systems fail six months in, quietly and expensively.
How can I help you explore Laravel packages today?