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
Browser Detect

Browser Detect Laravel Package

pataar/browser-detect

Detect browsers, operating systems, devices, and bots from the user agent in your Laravel application. pataar/browser-detect provides a simple API to identify visitors and tailor responses, logging, or feature checks based on their platform.

View on GitHub
Deep Wiki
Context7

Browser & Mobile detection package for Laravel.

Frequently asked questions about Browser Detect
How do I install pataar/browser-detect in a Laravel application?
Install it with Composer by running composer require pataar/browser-detect. The package is Laravel-oriented and registers itself through package auto-discovery, so manual service provider registration is normally unnecessary. After installing, publish the package config file so you can review its defaults, then verify detection in a non-production environment before rolling out.
Which Laravel and PHP versions does pataar/browser-detect support?
The package targets Composer-based Laravel applications, but the exact constraints live in its composer.json, so check the require block for the Laravel and PHP versions supported by the 5.4.0 release. Because 5.4.0 is a minor feature release on top of 5.3.2, upgrading from 5.3.x is expected to be low risk. Confirm compatibility in staging before upgrading production.
How do I detect a visitor's browser, operating system, and device type in Laravel?
You parse the current request's user agent through the package's facade or helper and read back the detected browser, operating system, device type, and bot status. Detection relies on user-agent parsing, so results reflect what the client sends and can be spoofed or incomplete. Call it where you need it, such as middleware, controllers, or logging, and avoid re-parsing the same user agent on hot paths unless caching is enabled.
How do I detect bots and crawlers with pataar/browser-detect?
The package identifies bots and crawlers alongside browsers, operating systems, and devices, so you can branch on bot status to skip analytics, serve different content, or route traffic differently. Check the bot result before doing expensive rendering or personalization work for known crawlers. Validate against representative search engine and monitoring bot user agents, since bot signatures change over time.
How do I enable the device-detector cache added in pataar/browser-detect 5.4.0?
Version 5.4.0 adds an optional device-detector cache layer that is intended to be opt-in. Enable it through the package configuration rather than changing application code, which keeps the upgrade from 5.3.2 straightforward. After enabling, run detection against known browsers, bots, and edge-case user agents to confirm results still match what you saw with caching disabled.
Which cache store should I use for Laravel browser detection caching in production?
Because caching goes through Laravel's cache abstraction, it should work with any configured store, including Redis, Memcached, file, database, and array. In production, prefer a shared, low-latency store such as Redis or Memcached so cache hits actually reduce user-agent parsing cost across your app servers. Avoid per-instance stores like the array driver if detection results need to be consistent across servers.
Can I configure the cache TTL, and what is the default?
The 5.4.0 release introduces cache configuration for device detection, so review the published package config after upgrading to see the default TTL and whether it can be overridden. A longer TTL reduces parsing CPU but keeps results around longer when detection rules change, while a shorter TTL does the opposite. If your version does not clearly expose a TTL setting, confirm the behavior with the maintainer before relying on it.
Are cached detection results namespaced so multiple Laravel apps or tenants do not collide?
Cache keys are generated by the package, so verify whether they include an application or tenant prefix before enabling caching across multiple Laravel apps that share one Redis or Memcached instance. Without a namespace, identical user-agent strings in different apps could share cached entries, which is usually harmless but confusing when dependency versions differ. If the keys are not scoped, configure a separate cache store or prefix per application or tenant.
What happens if the cache store is down or cached results become stale after a device-detector update?
Cached results can go stale when device-detector rules or its regex database are updated, because entries reflect the parser version that produced them. Plan to invalidate or clear the cache after dependency updates and choose TTLs so stale entries age out on their own. If the cache backend is unavailable, behavior depends on the package's fallback handling, so test that path explicitly before relying on caching in production.
How does pataar/browser-detect compare to jenssegers/agent, and is it still maintained?
pataar/browser-detect is a Laravel wrapper around user-agent parsing and is often compared with packages like jenssegers/agent, which exposes a similar detection API. The main differentiator here is the optional device-detector cache added in 5.4.0, which matters if you parse user agents on hot paths such as middleware or analytics ingestion. The project is community-maintained, so check recent releases, open issues, and contributor activity before committing long term.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource