geisi/laravel-db-session-helper
A small Laravel helper package for working with database-backed sessions, offering convenience utilities around session storage. Lightweight and easy to drop into existing Laravel apps that use the database session driver.
Architecture fit. v0.0.2 is a Laravel/PHP Composer package providing presence tracking (online/offline) for Eloquent models, exposed through a trait plus isOnline / isOffline query scopes. This is idiomatic Laravel: package auto-discovery, a service provider, a trait on the model, and scopes composed into existing query builder chains. It slots into the framework with no architectural conflict, and the scope-based API is preferable to a per-row accessor because it lets presence be filtered at the database rather than hydrated into PHP.
Integration feasibility. Install cost is low (composer require, optional migration for the presence column, trait on the target model). The surface area is small enough for a spike in a day. Feasibility is gated less by the package than by our own schema: presence scopes need an indexed timestamp column and a defined staleness window, both of which are our decisions, not the package's.
Technical risk. v0.0.2 is a correctness release, and what it reveals matters more than what it fixes:
datetime('now', '-5 minutes')) or otherwise depended on SQLite date semantics. Any team that shipped v0.0.1 against MySQL/Postgres/MariaDB would have hit exceptions on the presence query path. This is a strong signal the package's CI matrix did not cover production-grade database engines.Two defects of this class in a 0.0.x line indicate a thin test suite and no consumer validation before publish. The risk is not that these specific bugs persist (they are fixed) but that the defect class is likely to recur. Treat every upgrade as requiring a behavioural diff, not just a green build.
Key questions. (1) Is presence backed by a database column or the cache, and if the cache, is that consistent across multiple app nodes? (2) Is the online threshold configurable, and is it evaluated against the database clock or the PHP clock — the latter introduces timezone and clock-skew drift? (3) Which Laravel and PHP versions are supported, and is there a published CI matrix covering MySQL 8, MariaDB, and Postgres? (4) Does the scope push a WHERE to the database or filter in PHP after hydration? (5) Are the scopes indexed-friendly, and is there a documented recommended index? (6) Does any of this break under Laravel Octane, where long-lived workers could cache stale state?
Stack fit. Framework-native and database-agnostic as of v0.0.2 — the release note is effectively the vendor's claim of portability, and it needs verification rather than trust. It fits any Eloquent model with a writable presence timestamp or cache key; no new infrastructure is required if presence is column-backed.
Migration path. If presence is column-backed, this is a schema change: additive nullable column, backfill of unknown state, then a dual-write window where the application continues writing its existing last_seen_at/updated_at while the package begins reading it. Pin the exact version (0.0.2, not ^0.0) — a 0.0.x caret range will float into the next patch, and the next patch is where the next correctness fix lives.
Compatibility. Verify against our engine before merge. SQLite-in-CI proves nothing here; the package has just demonstrated that. Run the same integration suite against the production engine version, including the scope assertions (isOnline and isOffline must be mutually exclusive and exhaustive over a seeded fixture with known timestamps at the boundary of the staleness window).
Sequencing. (1) Spike on a dev branch with the production engine, not SQLite. (2) Write boundary tests around the online threshold before adopting — this is the only way to catch a recurrence of the "scopes weren't applied right" class. (3) Add the column and index in staging; measure query plans on a production-sized table. (4) Roll out reads behind a config flag, keeping the existing presence logic live as the source of truth. (5) Cut over, then remove the duplicate logic. Do not adopt this package for anything user-visible (online-now indicators, "reachable" gating, notification targeting) until step 2 passes.
Maintenance. Pre-1.0 with no stability guarantee; the API may move under us. Budget for reading every changelog line, and expect the current 0.0.x cadence to continue. Consider a thin internal wrapper around the trait and scopes so an upstream break is a one-file fix and, if necessary, a fork point. If the package is unmaintained, the wrapper is what makes vendoring cheap.
Support. Assume a single maintainer and no LTS. Escalation is upstream issues, not a vendor SLA. Mitigate by keeping the wrapper thin enough to own outright — the functionality is not complex, and our tolerance for waiting on a fix should be low given the defect history.
Scaling. Presence is a hot-path concern. Column-backed scopes over a large users table require a composite index appropriate to the query shape; without it, "who is online" becomes a sequential scan on every dashboard load, notification batch, or API call. Watch for per-row accessor calls in Blade loops (N+1) and for polling clients multiplying the read rate. If write volume on the presence column is high, evaluate a cache-backed presence store instead of a database column — the database column turns every heartbeat into an UPDATE, which is the expensive pattern at scale.
Failure modes.
Ramp-up. Low learning curve: one trait, two scopes, one optional migration. The real onboarding cost is institutional — teaching the team the staleness window, that "online" is a heuristic rather than a fact, and that the scopes must be verified against the production engine on every upgrade. Document the threshold value and its rationale next to the model; that number is a product decision that will be questioned later.
Verdict. Adopt for internal, non-user-visible use after engine-specific verification; defer user-facing presence features until the boundary tests pass and a release pattern exists beyond two bug-fix patches. The v0.0.2 fixes are meaningful and necessary — they make the package usable outside SQLite and restore the correctness of its core feature — but they are also evidence that this package has not yet been exercised against production conditions by anyone, including its author.
How can I help you explore Laravel packages today?