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

Influxdb Client Php Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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.

  • Vendor roadmap. InfluxData's investment is centered on InfluxDB 3.x (SQL/Flight). This is a 2.x reference client; assume maintenance-mode posture over a multi-year horizon. Verify the vendor's support policy for 2.x before committing as a system of record.
  • Runtime semantics. The batching 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.
  • Failure visibility. Default synchronous writes block the request up to timeout (default 10s); batched writes can swallow failures unless the error callback is wired. Neither default is acceptable on a user-facing request path.
  • Injection surface. Parameterized queries are Cloud-only per the README. If we self-host OSS, any user-influenced value in Flux must be validated/allowlisted — there is no sanctioned parameterization backstop.
  • Ecosystem depth. 166 stars and 0 listed dependents is low validation for the integration patterns we'd want. Being the vendor's own repo mitigates bus factor somewhat, but it does not give us recipes, third-party test doubles, or a large pool of hiring signal.
  • No Laravel-native testing story. No official fake or in-memory implementation; we must build one or our test suite either hits a real instance or asserts nothing.
  • Secrets. Tokens are plain config values; multitenancy pushes toward per-tenant tokens or a broad admin token, both of which are governance decisions, not library decisions.

Key questions.

  1. Is this telemetry for internal observability (best-effort is fine) or a customer-facing analytics feature (SLA, retention, and DR commitments apply)? The answer changes the entire design.
  2. Target is InfluxDB 2.x OSS, Cloud, or 3.x? What is the vendor's published support window for 2.x?
  3. Should the PHP app write directly, or emit to a local OTel Collector/Telegraf agent that owns buffering, retry, and backpressure? The agent pattern removes an entire class of failure modes from the application.
  4. What are our tolerances for lost points, write latency added to requests, and duplicate points (idempotency via point identity)?
  5. Who owns the measurement/tag schema, and how do we prevent cardinality sprawl? This needs a named owner before the first write, not after the first outage.
  6. Are buckets provisioned by Terraform or by application code? Pick one.
  7. FPM, Octane, or queue workers for the write path — and does that decision survive the next infrastructure change?

Integration Approach

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.

  • Inject Guzzle explicitly with timeout (2–3s, not the 10s default), verifySSL true, and a connection pool sized to worker count; do not rely on PSR-18 discovery.
  • Write behind the queue (or an agent), never synchronously inside a request handler.
  • For Octane/queue workers, construct the writer per job and always close(); never hold a batched WriteApi across requests.
  • Ship an ArrayMetricsWriter/NullMetricsWriter fake in the same PR as the adapter so tests don't require a live database.
  • Keep a hard-coded, reviewed allowlist of metric names and tag keys in the adapter. Reject unknown tags at the boundary.

Migration path.

  1. Decide and validate (week 1). Confirm target deployment (2.x OSS vs Cloud), confirm the package's PHP constraint against our Laravel version, and spike writes to a scratch bucket from a branch. Record the InfluxDB 3.x exit assumption as an ADR.
  2. Scaffold (week 1–2). Config, provider, port + adapter, fake, one contract test, one smoke test against a disposable container.
  3. Shadow (week 2–3). Dual-write from a single non-critical event stream (e.g., job timings) alongside the existing sink. No read path depends on it. Compare counts.
  4. Cutover (week 3–5). Move the first dashboard to Flux, retire the corresponding legacy sink for that stream only, keep dual-write one release.
  5. Expand (quarter). Widen to business metrics; add server-side downsampling tasks and retention policies before volume grows, not after.
  6. Decommission legacy path and delete the old credentials.

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.

Operational Impact

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.

  • InfluxDB unavailable: synchronous writes block requests up to the timeout, producing a latency cascade from a non-critical dependency. Mitigate with short timeouts, queue decoupling, a circuit breaker, and explicit fail-open behavior that logs and drops rather than throwing into the user path.
  • Batch loss: process kill, OOM, deploy restart, or unflushed buffers on FPM shutdown. No durable spool exists in the client; if loss is unacceptable, the buffer must live outside PHP.
  • Octane cross-request leakage: a retained batched writer attributing one request's points to another. Prevent with per-request construction.
  • Auth drift: token rotation, scope changes, or per-tenant token misconfiguration surface as exceptions inside application code paths — catch and isolate at the adapter.
  • Precision mismatch: a precision setting that disagrees with the timestamp unit silently produces points decades off; pin it once in config and test it.
  • Retry storms: naive retry after an outage amplifies load exactly when the database is recovering. Exponential backoff with jitter, plus queue-level throttling and a dead-letter queue.
  • Management API side effects: ad-hoc bucket creation from app code causing drift from Terraform and duplicate/competing resources.

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.

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.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource