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

Mobile Detect Bundle Laravel Package

netbull/mobile-detect-bundle

Symfony bundle integrating Mobile Detect to identify phones, tablets, and desktop browsers. Provides services and Twig helpers for device-aware templates, redirects, and responsive behavior in Laravel-style PHP apps.

View on GitHub
Deep Wiki
Context7

Symfony 4/5/6 bundle for detect mobile devices, managing mobile view types, redirect to mobile version.

Frequently asked questions about Mobile Detect Bundle
Is netbull/mobile-detect-bundle a Laravel package?
No. It is a Symfony bundle built around the mobiledetect/mobiledetectlib library, so it ships a Bundle subclass, a DI extension with a configuration tree, a kernel.request listener, and a Twig view-name resolver rather than a Laravel service provider or facade. Laravel will not auto-register it, and there is no config:publish step. Only the underlying detection logic is portable to a Laravel application.
Can I install netbull/mobile-detect-bundle with Composer in a Laravel app?
Composer can download it, but it will not boot because your application has no Symfony kernel to register the bundle. Nothing in the package discovers itself in Laravel, so the container service, listener, and Twig helpers never become available. In practice this is reference code for a port, not an install-and-go dependency.
What is the best way to do mobile detection in Laravel instead?
Bind mobiledetect/mobiledetectlib as a singleton in a service provider, resolve it from the container, and pass the current request's user agent and headers into the detector. Wrap any redirect behavior in a small middleware registered on the web group. That reproduces the useful parts of this bundle in roughly 150 to 300 lines of code.
How much work is it to port this bundle to Laravel?
Plan for a port rather than a wrapper: a container binding for the detector, a middleware for redirect or view switching, and feature tests covering the decision matrix. That is typically one to three developer days for a hardened implementation with tests. The bundle's Symfony-specific machinery, including bundle registration, the config tree, and event listener wiring, is discarded entirely.
Does this package support Client Hints like Sec-CH-UA-Mobile?
No. Detection is user-agent string matching via mobiledetect/mobiledetectlib, and the 7.0.2 release adds no Client Hints support. User-agent sniffing degrades over time because of Android UA reduction, frozen UA strings, iOS Request Desktop Site, and in-app webviews. If accuracy matters, treat UA detection as a heuristic and prefer responsive layouts or feature detection for layout decisions.
Is redirecting mobile users to a separate mobile URL bad for SEO?
It can be. UA-conditional redirects to a separate mobile URL set are exactly what Google warns about, and misconfiguration easily produces redirect loops such as mobile to desktop to mobile. If Googlebot's smartphone user agent is served different content than a desktop agent, that can be read as cloaking. Responsive design avoids the whole category of risk.
How do you access the detector service from a controller or Twig template?
In the Symfony bundle the detector is registered as a container service, so you inject it via autowiring in controllers and use the provided Twig helpers or device view resolver in templates. Those integration points are Symfony-specific and do not exist in Laravel. In a Laravel port you would inject your own bound detector, or share it with views through a view composer.
Is netbull/mobile-detect-bundle actively maintained and safe for production?
The repo is a maintained fork of the older suncat/mobile-detect-bundle lineage, and the 7.0.2 release shows someone is keeping the 7.x line compatible with newer PHP runtimes. That said, it has around one star and zero dependents, so there is no ecosystem evidence it runs in production anywhere, and the bus factor is essentially one. Putting a near-zero-adoption dependency in the request path of every page is a poor supply-chain trade for a feature you can write yourself in a few hundred lines.
Which Symfony and PHP versions does the 7.x release support?
The 7.x major number implies Symfony 6 and 7 on PHP 8.2 or newer, which removes the old Symfony 2 to 5 and PHP 7 era constraints. Confirm this against the package's composer.json constraints rather than inferring it from the major version, since a fork can renumber independently. The 7.0.2 patch only fixes a PHP deprecation notice, so it signals compatibility maintenance rather than new functionality.
How do I test device detection in a Laravel application?
Write feature tests that hit your routes with a spoofed User-Agent header for a phone, a tablet, and a desktop browser, then assert the expected redirect or response. Because mobiledetect works purely from request headers, no external services or fixtures are needed. Also add cases for bot user agents and for desktop-mode mobile UAs, since those are where naive detection typically breaks.
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.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core