Try Depot: Bring ultra-fast, remote Docker builds directly to your Laravel workflow

Agent

jenssegers/agent image

Agent stats

Downloads
36.3M
Stars
4,286
Open Issues
76
Forks
437

View on GitHub →

Desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

Agent: Laravel User Agent Parser

Agent is a powerful PHP package for parsing user agent strings, designed to work seamlessly with Laravel. It is built on the well-regarded Mobile Detect library, enhanced with desktop support and additional functionalities for a more comprehensive user agent analysis.

Key Features

  • User Agent Parsing: Efficiently parse user agent strings to determine types of devices, browsers, and operating systems.
  • Mobile Detection: Detect various mobile devices including phones and tablets.
  • Desktop Detection: Identify desktop users, distinguishing them from mobile or tablet users.
  • Browser and Platform Analysis: Determine browser types and operating systems, including versions (in beta).
  • Robot Detection: Identify and differentiate robots from human users.
  • Language Extraction: Extract browser's accept languages from the user agent.
  • Device, OS, and Browser Information: Get detailed info about the device, operating system, and browser names.

Installation

Install the package via composer:

composer require jenssegers/agent

Laravel Integration (Optional)

Add the service provider and alias to your config/app.php:

Jenssegers\Agent\AgentServiceProvider::class,
'Agent' => Jenssegers\Agent\Facades\Agent::class,

Usage

Create an Agent instance or use the Laravel facade:

use Jenssegers\Agent\Agent;
$agent = new Agent();

Basic Methods

  • Check properties: $agent->is('iPhone');
  • Use magic methods: $agent->isAndroidOS();
  • Regular expression matching: $agent->match('regexp');
  • Get device, platform, or browser details: $agent->device(); $agent->platform(); $agent->browser();

Advanced Features

  • Get accept languages: $languages = $agent->languages();
  • Check if the device is a desktop: $agent->isDesktop();
  • Determine if the user agent belongs to a robot: $robot = $agent->robot();

Additional Information

Agent leverages the Mobile Detect library and is compatible with its methods. It also supports robot detection using the jaybizzle/crawler-detect package. For detailed examples and method descriptions, refer to the Mobile Detect documentation.

The package is licensed under the MIT License and contributors can report security vulnerabilities through the provided security contact steps.

With its comprehensive set of features, Agent is an essential tool for developers needing detailed user agent analysis in their Laravel applications.

jenssegers photo

Engineering Manager & Solution Architect at OTA Insight

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Jenssegers Agent Related Articles

OpenAI Releases GPT-5.3-Codex, a New Codex Model for Agent-Style Development image

OpenAI Releases GPT-5.3-Codex, a New Codex Model for Agent-Style Development

Read article
Laravel Announces Official AI SDK for Building AI-Powered Apps image

Laravel Announces Official AI SDK for Building AI-Powered Apps

Read article
Manage PostgreSQL Databases Directly in VS Code with Microsoft's Extension image

Manage PostgreSQL Databases Directly in VS Code with Microsoft's Extension

Read article
Install Laravel Package Guidelines and Skills in Boost image

Install Laravel Package Guidelines and Skills in Boost

Read article
Laravel Boost v1.8.10 Released With New AI Prompts and Livewire v4 Support image

Laravel Boost v1.8.10 Released With New AI Prompts and Livewire v4 Support

Read article
The Neuron AI Framework for PHP and Laravel image

The Neuron AI Framework for PHP and Laravel

Read article
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech