reefki/laravel-device-detector
Laravel integration for device detection that parses user agents to identify device type (mobile, tablet, desktop), OS, browser, and bots. Access results in Blade views, middleware, or anywhere in your app to serve tailored content, redirect traffic, and improve analytics.
Architecture fit. The package is an idiomatic Laravel wrapper: a service provider registering a singleton binding, a facade, a publishable config file, and (typically) a cache-backed adapter around Matomo's DeviceDetector. It introduces no schema, no queue, no background workers, and no cross-cutting concern beyond user-agent parsing, so it slots into the container without disturbing existing architecture. The detector itself is stateless per request, which is the right shape for both monolith and API workloads.
Integration feasibility. Low effort: composer require, optional vendor:publish for config, optional binding of a PSR-6/PSR-16 cache pool to avoid re-parsing. The wrapper's own code surface is small — the intellectual property is almost entirely upstream Matomo. This makes a time-boxed spike cheap and reversible.
Technical risk. This is where the package needs scrutiny, not the technology. 31 stars and 0 dependents means effectively no public production validation, no downstream issue reports, and a single-maintainer bus factor. The stated last release date is future-dated, which is a metadata anomaly worth verifying against Packagist and the repo's tag history before relying on active maintenance. Mitigating factors: (a) the upstream Matomo DeviceDetector is mature, widely deployed inside Matomo itself, and actively refreshed with regex/YAML data; (b) the wrapper is thin enough to vendor or replace with ~20 lines of direct instantiation if abandoned. The real risk is therefore dependency hygiene, not parsing correctness. One non-obvious item: the wrapper is MIT but upstream DeviceDetector is LGPL-3.0-or-later — confirm obligations if you redistribute the application or ship it to customers.
Key questions for the maintainer / spike.
Sec-CH-UA*) capture supported, or only raw user-agent parsing? Without it, Chromium's UA reduction degrades accuracy materially.unknown, exception)?Stack fit. Assumes a conventional Laravel app on PHP 8.1+ with Redis or memcached available. Natural insertion points: HTTP middleware that attaches a request-scoped device DTO, form requests, audit/analytics event enrichment, and fraud or rate-limiting rules keyed on device/bot classification. It is not a fit for CLI or queue workers unless the UA string is carried explicitly.
Migration path. Most teams arrive here replacing jenssegers/agent, mobile-detect, or raw get_browser(). Do not let the facade leak into domain code: define an internal DeviceContext interface (device type, OS, browser, version, brand/model, bot flag) and implement it with this package behind an adapter. That keeps the swap-out cost near zero and lets you A/B the new detector against the incumbent on real traffic before committing.
Compatibility considerations. Pin the upstream Matomo DeviceDetector to an exact version — the regex database ships with the library, so loose constraints can shift classification behavior between deploys. Caching is not optional at any real traffic volume; treat the cache pool as a first-class configuration item. If Client Hints are needed, the headers must be captured at the edge/reverse proxy before they are stripped.
Sequencing.
Maintenance. Ongoing work is dominated by dependency bumps rather than wrapper changes — budget a recurring composer update cadence and a post-upgrade diff of classification results against your fixture corpus. Because the wrapper is small, the abandonment scenario is a contained afternoon of work, not a migration project; document that fallback path now rather than after it is needed.
Support. No commercial backing and a negligible community mean internal ownership is mandatory. Assign a named owner and pin the version. Do not expect upstream wrapper fixes on any SLA; upstream Matomo fixes arrive on Matomo's cadence, which is generally healthy.
Scaling. The service is stateless and scales horizontally without thought. Performance is entirely a function of the regex parse versus cache hit ratio: warm hits are sub-millisecond, cold parses are single-digit milliseconds plus the memory footprint of the regex dataset per worker. Size the cache and pre-warm after deploys.
Failure modes to design for.
Ramp-up. A Laravel developer is productive in hours. The non-trivial investment is building the UA fixture corpus, a regression harness, and monitoring of the unknown/ambiguous classification rate — plan days, not hours, for that surrounding instrumentation, and treat it as the actual deliverable rather than the package itself.
How can I help you explore Laravel packages today?