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 Bundle

Device Detector Bundle Laravel Package

acsiomatic/device-detector-bundle

Symfony bundle integrating Matomo DeviceDetector. Provides a configured DeviceDetector service for the main request plus Twig global and routing condition support. Detect devices, browsers/clients, OS, brands/models, and bots with optional caching and auto-parse.

View on GitHub
Deep Wiki
Context7
Frequently asked questions about Device Detector Bundle
Can I use AcsiomaticDeviceDetectorBundle directly in Laravel without Symfony?
No, this bundle is designed for Symfony. For Laravel, you’ll need to either use a Symfony Bridge like `spatie/symfony-laravel-bridge` or manually wrap the underlying `matomo-org/device-detector` library in a Laravel service provider. The README provides a basic example for standalone Laravel integration.
What Laravel versions does this bundle support?
The bundle itself targets Symfony 6.4+, but Laravel compatibility depends on your integration method. If using `spatie/symfony-laravel-bridge`, ensure your Laravel version (8.x+) aligns with the bridge’s Symfony compatibility. For vanilla Laravel, the core `matomo-org/device-detector` supports PHP 8.1+.
How do I configure caching for device detection in Laravel?
Caching is configured via Symfony’s cache pool (e.g., `cache.app`). If using the Symfony Bridge, set `pool: 'cache.app'` in `config/packages/acsiomatic_device_detector.yaml`. For vanilla Laravel, manually integrate a cache driver (e.g., Redis) into the `DeviceDetector` service wrapper.
Will this bundle slow down my Laravel app if `auto_parse: true`?
Yes, auto-parsing adds overhead per request. For high-traffic apps, disable auto-parsing (`auto_parse: false`) and manually trigger parsing only when needed. Cache results aggressively (e.g., middleware + Redis) or use a facade to lazy-load detection.
Can I customize device detection rules (e.g., add support for niche devices)?
Yes, the underlying `matomo-org/device-detector` supports custom parsers. Extend the `Parser` class or override the service registration in Laravel to inject custom rules. Refer to the [DeviceDetector documentation](https://github.com/matomo-org/device-detector) for parser customization.
How do I access device data in Laravel Blade templates?
This bundle doesn’t natively support Blade, but you can expose the `DeviceDetector` service via a facade or helper. For Symfony Bridge users, create a Twig extension to bridge data to Blade. Example: `{{ device.isMobile() ? 'Mobile' : 'Desktop' }}` in Twig can be replicated in Blade with `$deviceDetector->isMobile()`.
Does this bundle work with Laravel’s route model binding or middleware?
Yes, but indirectly. The bundle provides a routing condition service (e.g., `device`) for Symfony. In Laravel, use middleware to inject the `DeviceDetector` service into the request or bind it to route parameters via a custom resolver. Example: `Route::get('/mobile', [Controller::class, 'show'])->middleware('device:isMobile');`
What’s the best alternative for Laravel if I don’t want to use Symfony components?
For vanilla Laravel, consider `jenssegers/agent` (lighter, Laravel-native) or directly use `matomo-org/device-detector` via a service provider. `jenssegers/agent` is simpler for basic detection but lacks advanced features like Client Hints parsing. Compare your needs: analytics vs. UX personalization.
How do I test device detection logic in Laravel?
Mock the `DeviceDetector` service in tests. For Symfony Bridge users, override the service in PHPUnit with a mock that returns predefined device data. Example: `$this->app->instance(DeviceDetector::class, $mockDetector);`. Test edge cases like bots, custom User-Agents, and caching behavior.
Can I disable bot detection entirely to improve performance?
Yes, set `skip_detection: true` in the bundle config to bypass bot checks. This skips the bot detection logic entirely, treating all requests as regular devices. Useful for high-traffic APIs where bot detection isn’t critical. Trade-off: lose bot-specific analytics.
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope