Looking to hire Laravel developers? Try LaraJobs

laravel-user-device maintained by vuthaihoc

Description
A modern Laravel package replacing jenssegers/agent, acting as a wrapper for MobileDetect.
Last update
2026/05/26 11:16 (dev-main)
Links
Downloads
0

Comments
comments powered by Disqus

Laravel User Device (Agent)

A modern Laravel package replacing jenssegers/agent, acting as a lightweight wrapper around mobiledetect/mobiledetectlib v4. It maintains backwards compatibility with \Agent::... calls by providing the same facade methods.

Requirements

  • PHP >= 8.2
  • Laravel 12.0 or 13.0+
  • mobiledetect/mobiledetectlib ^4.0

Installation

You can install the package via composer:

composer require vuthaihoc/laravel-user-device

Configuration

The package automatically registers its ServiceProvider and Facade thanks to Laravel Package Discovery. No additional configuration is needed.

Usage

You can use the \Agent facade directly in your Laravel application just like you did with jenssegers/agent:

// Basic device detection
$device = \Agent::device(); // Returns device name or false
$robot = \Agent::robot();   // Returns robot name or false

// MobileDetect methods (forwarded dynamically)
\Agent::isMobile();
\Agent::isTablet();
\Agent::is('iPhone');
\Agent::getUserAgent();

// Legacy methods compatibility
\Agent::getBrowsers();
\Agent::getOperatingSystems();
\Agent::getPlatforms();
\Agent::getDesktopDevices();
\Agent::getDetectionRulesExtended();
\Agent::getScriptVersion();

Included Compatibility Methods

This package implements or forwards the following methods to ensure a smooth transition from jenssegers/agent:

  • device()
  • robot()
  • getDetectionRulesExtended()
  • getBrowsers()
  • getOperatingSystems()
  • getPlatforms()
  • getDesktopDevices()
  • getProperties()
  • getScriptVersion()
  • getPhoneDevices()
  • getTabletDevices()
  • getUserAgents()
  • getUtilities()
  • getMobileDetectionRules()

License

The MIT License (MIT).