highideas/laravel-users-online
Track which users are online in your Laravel app with this lightweight package. It records activity via cache or database drivers, lets you check online status, list active users, and configure timeouts, with simple helper methods and Blade-friendly access.
Architecture fit. The package is a thin Laravel utility — a service provider, a middleware that records user activity, and an Eloquent scope/query for "online" users — so its architectural footprint is small and it slots cleanly into a conventional Laravel MVC monolith with session-based auth. It targets nothing exotic (no queue infrastructure, no event sourcing, no multi-tenant awareness), which makes it easy to reason about but also limits it: it assumes a single app, single auth guard, and a shared session store. There is no clean story for distributed deployments beyond what the underlying session driver already provides.
Integration feasibility. Installation is standard Laravel: Composer require, auto-discovered service provider, vendor:publish for config and migration. The logic surface is small enough to read and audit in an afternoon, which is a genuine advantage — if the package is incompatible, the fallback (vendor the ~200 lines of middleware + model scope) is cheap. The real integration question is not effort but version compatibility.
Technical risk. This is the dominant concern and it is high:
$dates, deprecated facade helpers).last_activity semantics. With Redis/database sessions this can behave differently than with file sessions, and multi-node deployments need a shared store or the "online" count fragments.last_activity on every request (the common pattern), that is a DB write per authenticated request — a real cost at scale and a source of lock contention.Key questions for engineering.
composer.json constraint allow them as-is?users.last_activity, a dedicated table, or the session store? What is the per-request write cost?Authenticate middleware, or a global middleware — and does that conflict with our existing audit/activity logging?Auth primitives or our existing activity log rather than adding a dependency?TPM read. Low opportunity score (1.9) + 2019 release date + small surface area points to a "don't adopt, re-implement or fork" decision rather than a dependency bet. The feature is genuinely small; the risk is in the dependency, not the problem.
Stack fit. Fits a standard Laravel monolith on the same major version it was built for (≈ Laravel 5.5–6, PHP 7.1–7.4). On Laravel 10/11/12 the package will not install cleanly; the logic is still reusable but the package as shipped is not.
Migration path. Two viable routes, chosen by our current framework version:
web group, add a scheduled cleanup command, and put the "online count" behind a feature flag. Accept that we are now the de-facto maintainer.app/Support/OnlineUsers module), upgrade signatures to PHP 8, replace deprecated helpers, and drop the external dependency. This preserves the feature, removes the abandonment risk, and gives us control over write cost.Compatibility. Validate before committing: Composer constraint vs. our laravel/framework and PHP versions, presence of deprecations ($dates, getDateFormat, container bind signatures), and whether the published migration collides with an existing users schema. Run the package's tests (if any) on our PHP version as a smoke check — expect failures on 8.2+.
Sequencing.
Maintenance. This is the headline cost. Adopting the package means inheriting an unmaintained dependency with no upgrade path across eight Laravel majors. Every framework bump becomes our bug. Forking transfers that burden explicitly, which is arguably better than discovering it silently. Budget ongoing ownership either way — there is no "install and forget" here.
Support. Effectively none from upstream: last release 2019, low star count, low opportunity score, no signal of an active maintainer. Internal support requires someone who has read and understood the tracking logic — keep it small, documented, and owned by the platform team.
Scaling. The naive implementation (write last_activity per request) does not scale gracefully: it adds a write to every authenticated request, drives DB contention, and inflates the "online" query cost as the users table grows. Mitigations: batch activity stamps (e.g., only update if last write > N seconds ago), push the "who is online" set into Redis with TTL, and index the activity column. Multi-node correctness depends on a shared session/cache store — file sessions will fragment the count per node.
Failure modes.
Ramp-up. Low learning curve — the feature is simple and the codebase is small — but ramp-up is dominated by compatibility and hardening work, not comprehension. Realistic effort: ~0.5 day to evaluate, 1–2 days to fork/fix or re-implement, ~0.5–1 day to harden for multi-node and cleanup. The TPM recommendation is to treat this as a small in-house capability rather than a third-party dependency, since the logic is cheap to own and the package's staleness and low opportunity signal make adoption a net liability.
How can I help you explore Laravel packages today?