sinergi/browser-detector
Lightweight PHP library for detecting browser, operating system, device, and language from user agent strings. Uses targeted regex rules instead of a bloated UA database, with simple detectors and optional Laravel service provider and facade integration.
Architecture fit
Browser, OS, and Language detector classes. The "Laravel-native" path exists, but the core value is the regex tables, not the integration glue.Integration feasibility
composer require sinergi/browser-detector, followed by manual provider registration on Laravel 10/11 (do not assume package auto-discovery). 6.1.4 is a patch bump within the same major/minor line, so it is a drop-in upgrade for anyone already on ^6.1 — no code changes, no adapter changes, no migration.BrowserInfo) that can be logged, cached, and asserted against.Technical risk
composer.json PHP constraint against your target (8.2/8.3) and watch for dynamic-property deprecations that strict error handlers escalate to exceptions. A patch release is unlikely to have moved the constraint — confirm rather than assume.Key questions
matomo/device-detector. Confirm the fix lands and check for regressions in neighbouring Chrome/Chromium patterns.matomo/device-detector? Still the gating benchmark, now with Edge removed from the known-disagreement set so the residual gap is cleaner to read.Stack fit
$request->userAgent() and $request->header('Accept-Language'). No storage, migration, or infrastructure prerequisite.Request::userAgent()), so the added value is strictly the parsing/normalization layer.Migration path
BrowserDetectorInterface in a service provider and implement SinergiBrowserDetector behind it. This remains the single highest-leverage decision: it converts a low-activity dependency into a swappable adapter.browser_detector.driver = sinergi | matomo) so a replacement can be rolled out per environment without a code change. Still a few hours now versus a refactor later.6.1.4 explicitly in composer.lock and tighten the constraint from floating to a caret pin at minimum, ideally an exact pin. Prior guidance to forbid floating constraints stands — and the arrival of an unexpected patch is precisely the scenario that guidance was written for.Compatibility
Sequencing
matomo/device-detector over a 10k-UA production sample; quantify disagreement rate by browser family and bot classification. Report Edge as a separate line item pre/post upgrade.Maintenance
6.1.4 exactly, forbid floating constraints, and prefer a vendored fork if patching is anticipated. The upside of vendoring is now clearer — upstream patches like this one become cherry-pickable rather than a dependency on someone else's merge latency.Support
Scaling
Accept-Language. 6.1.4 adds a pattern to the table, so per-invocation cost ticks up marginally — immaterial, but another argument for the cache.Failure modes
| Failure | Impact | Mitigation |
|---|---|---|
| Misclassification (Brave/Arc, frozen Safari UA, future Chromium derivatives) | Skewed analytics, wrong UI branch | Restrict to non-decisional uses; shadow-mode benchmark. Edge-on-Chromium removed from this row as of 6.1.4. |
| Historical discontinuity from the 6.1.4 reclassification | Dashboards show a false Edge step-change; looks like a regression | Annotate cutover date; regenerate golden files; notify analytics consumers |
| Regression in adjacent Chrome/Chromium patterns | New misclassification introduced by the patch | Golden-file diff before merge; shadow mode |
| PHP deprecations on 8.2/8.3 under strict handlers | Exceptions in request path | Fork with lifted constraint; CI matrix |
| Empty or malformed UA | Null/default values downstream | Null-object value type; explicit fallback tests |
| Bot list staleness | Headless/automation miscounted as human | Do not rely on this for fraud or rate limiting |
Locale derived from Accept-Language only |
Wrong default language for some users | Treat as a default, always allow explicit override |
| Another multi-year upstream gap | Blocked on unpatched detections | Adapter interface makes driver swap a config change; vendored fork |
Ramp-up
Recommendation: upgraded from "default to the maintained alternative" to "viable as a low-stakes enrichment utility behind an adapter interface, with an explicit owner and a planned exit path." 6.1.4 removes the strongest single argument against adoption (a named, real misclassification of a major browser) and demonstrates upstream is not sealed. It does not supply a maintenance cadence, Client Hints support, or a CVE process, so the constraints stand: not acceptable as a dependency for any user-facing entitlement, security, or bot-management decision. Run the accuracy benchmark including the new Edge slice; if the residual gap versus matomo/device-detector is now narrow, adopt this package pinned at 6.1.4 rather than switching — the switching cost is no longer clearly justified by the data alone.
How can I help you explore Laravel packages today?