Weave Code
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
Device Detector

Device Detector Laravel Package

matomo/device-detector

Parses User-Agent strings and browser Client Hints to identify device type (desktop/tablet/mobile/TV/console), client apps (browsers, media players, feed readers), operating systems, and device brand/model. Composer-ready PHP library.

View on GitHub
Deep Wiki
Context7

The Universal Device Detection library will parse any User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model.

Frequently asked questions about Device Detector
How do I install this package in a Laravel project?
Run `composer require matomo/device-detector` in your project root. No additional Laravel-specific setup is required for basic usage, though middleware or service provider integration is recommended for production.
Does this package support Laravel’s caching systems (Redis, file, etc.)?
Yes, it integrates with Laravel’s cache bridges via PSR-6/PSR-16. Configure caching in `config/services.php` to store parsed results and improve performance. Redis is ideal for distributed environments.
Can I use this for bot detection in Laravel?
Absolutely. The library includes bot detection capabilities. Parse the User-Agent with `$dd->isBot()` and use middleware to filter or log bot traffic before it reaches your routes.
Which Laravel versions are officially supported?
The package requires PHP 7.4+ and works with Laravel 8.x, 9.x, and 10.x. Check the [GitHub repo](https://github.com/matomo-org/device-detector) for version-specific compatibility notes.
How do I integrate this with Laravel middleware?
Create a middleware class that instantiates `DeviceDetector` with `$request->userAgent()`, calls `$dd->parse()`, and attaches results to `$request->merge(['device' => $dd])`. Register it in `app/Http/Kernel.php` under the `web` middleware group.
Will this work with Client Hints (Accept-CH header) in Laravel?
Yes, but you must configure your server to send the `Accept-CH` header. The library falls back gracefully to `HTTP_USER_AGENT` if Client Hints are unavailable. Test with headers like `Sec-CH-UA` for modern browsers.
How accurate is device detection for edge cases (e.g., custom User-Agents, bots)?
The library uses regex-based parsing with high accuracy for common devices/browsers. For custom User-Agents, extend the YAML parser rules or test with real-world samples. Bot detection may require tuning for false positives.
Can I store detected device data in a Laravel database?
Yes. Create Eloquent models for `DeviceDetection` and log parsed data (e.g., `user_agent`, `device_type`, `is_bot`). Use query scopes like `DeviceDetector::where('is_mobile', true)` for filtering.
What are the performance implications of parsing User-Agents on every request?
Regex parsing adds minimal overhead (~1–5ms per request). Mitigate this by caching results in Redis or a file cache. For high-traffic apps, lazy-load detection or pre-warm caches during off-peak hours.
Are there alternatives to this package for Laravel?
Alternatives include `mobile-detect` (lighter but less feature-rich) or `ua-parser` (similar functionality but less Laravel-optimized). This package stands out for its Client Hints support, modularity, and Laravel cache integration.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi