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
Mobile Detect Bundle

Mobile Detect Bundle Laravel Package

suncat/mobile-detect-bundle

Symfony bundle integrating Mobile_Detect to identify phones/tablets by user agent, manage device-specific views (mobile/tablet/full), and optionally redirect users to mobile or tablet versions of your site. Supports Symfony 2.4–4.0.

View on GitHub
Deep Wiki
Context7

Symfony 2/3/4 bundle for detect mobile devices, manage mobile view and redirect to the mobile and tablet version.

Frequently asked questions about Mobile Detect Bundle
Can I use this bundle directly in Laravel without Symfony?
No, this is a Symfony bundle. However, you can leverage its underlying library, `Mobile_Detect`, by installing `serbanghita/mobile-detect` via Composer and integrating it into Laravel middleware or service providers. This avoids Symfony dependencies entirely.
How do I implement mobile/tablet detection in Laravel using this bundle’s approach?
Install `serbanghita/mobile-detect` via Composer, then create a Laravel middleware class that instantiates `Mobile_Detect` and checks for mobile/tablet devices. Use this middleware to conditionally load views or redirect users via Laravel’s routing system.
Will this bundle work with Laravel 8/9/10?
The bundle itself is Symfony-only, but its core library (`Mobile_Detect`) is framework-agnostic and works with Laravel. You’ll need to manually integrate the detection logic into Laravel’s middleware or service container, which is compatible with all modern Laravel versions.
How do I redirect mobile users to a separate URL (e.g., m.example.com) in Laravel?
Use Laravel’s `redirect()` helper or `Redirect` facade in middleware. First, detect the device with `Mobile_Detect`, then redirect mobile users with `return redirect()->to('https://m.example.com');`. Cache the detection result per session to avoid repeated parsing.
Does this bundle support tablet-specific views in Laravel?
Yes, but you’ll need to implement it manually. Use `Mobile_Detect` to identify tablets, then dynamically load tablet-specific Blade templates (e.g., `tablet.blade.php`) or apply CSS classes via view composers or middleware.
Are there performance concerns with parsing User-Agent strings on every request?
`Mobile_Detect` is lightweight, but parsing User-Agent strings on every request adds minor overhead. Mitigate this by caching the detection result in the session or Redis for repeated requests from the same device.
How do I test mobile detection logic in Laravel?
Mock the `Mobile_Detect` instance in your tests using Laravel’s testing helpers. Override the `isMobile()`, `isTablet()`, or other methods to simulate different devices. Test middleware and route responses using Laravel’s HTTP test clients.
What’s the best way to handle mobile detection in production?
Deploy the detection logic in middleware and cache results per session or IP (if acceptable). Monitor false positives/negatives by logging detected devices and user feedback. Consider A/B testing mobile vs. desktop experiences to validate effectiveness.
Are there Laravel-native alternatives to this bundle?
Yes, consider packages like `jenssegers/agent` (simpler User-Agent parsing) or `spatie/laravel-activitylog` for device-based feature flags. For full mobile detection, `Mobile_Detect` via middleware remains the most robust option.
How do I configure this for Laravel without Symfony’s YAML files?
Skip the bundle’s Symfony config entirely. Publish a Laravel-compatible config file (e.g., `config/mobile-detect.php`) using a package service provider, or use environment variables to define mobile/tablet detection rules and redirect paths.
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.
yandex/translate-api
voku/simple_html_dom
league/flysystem-vfs
bkwld/upchuck
filament/spatie-laravel-tags-plugin
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