cpoint-eu/mobile-detect-bundle
symfony/framework-bundle (v5.x) and mobile-detect/mobile-detect-lib (v2.8.x). Compatibility with other Symfony bundles (e.g., security, routing) is high.redirect component) or via JavaScript (e.g., for SPAs)?/api, /admin)?mobile-detect-lib supports PHP 8.x, ensuring compatibility with modern PHP stacks.cache:app) to reduce user-agent parsing overhead.composer require cpoint-eu/mobile-detect-bundle
config/bundles.php:
CpointEu\MobileDetectBundle\CpointEuMobileDetectBundle::class => ['all' => true],
config/packages/cpoint_eu_mobile_detect.yaml:
cpoint_eu_mobile_detect:
redirect:
enabled: true
mobile_path: '/mobile'
desktop_path: '/desktop'
exclude_paths: ['/api', '/admin']
detection:
strict: false # Adjust based on accuracy needs
config/routes.yaml or via annotations.kernel.request to log device types).mobile-detect-lib for breaking changes (e.g., new PHP versions or detection logic updates).MobileDetectBundle events and device detection results.error_log($request->headers->get('User-Agent'))).mobile-detect-lib has extensive documentation.cache:app).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| User-agent parsing error | Redirects fail or incorrect device | Fallback to desktop view or log error. |
| Symfony config misconfiguration | Bundle disabled or misbehaving | Validate config via symfony console debug:config. |
| High traffic + slow detection | Increased latency | Cache detection results per request. |
Outdated mobile-detect-lib |
Poor device detection accuracy | Regularly update dependencies. |
| Redirect loops | Infinite redirects | Exclude mobile paths from redirects. |
MobileDetectService)./api) are not redirected.How can I help you explore Laravel packages today?