PHPackages                             jorisvanw/agent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jorisvanw/agent

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jorisvanw/agent
===============

A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

v3.1.0(8y ago)0750MITPHPPHP &gt;=5.3.0

Since Nov 30Pushed 7y ago1 watchersCompare

[ Source](https://github.com/jorisvanw/agent)[ Packagist](https://packagist.org/packages/jorisvanw/agent)[ Docs](https://github.com/jorisvanw/agent)[ RSS](/packages/jorisvanw-agent/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (25)Used By (0)

Agent
=====

[](#agent)

[![Latest Stable Version](https://camo.githubusercontent.com/271d44959a3f76895957e19f56ca1d8b7bc4fd205f035e3b21cd9bcb52601025/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a656e737365676572732f6167656e742e737667)](https://packagist.org/packages/jenssegers/agent) [![Total Downloads](https://camo.githubusercontent.com/88327d027275f53f5064e0dee740bad0e13d9509c4179834668f1685e027c798/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6a656e737365676572732f6167656e742e737667)](https://packagist.org/packages/jenssegers/agent) [![Build Status](https://camo.githubusercontent.com/91af19d4b79b62b18d731bc90f41edb95103a319e3a10691b76b725e3ce7d955/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6a656e737365676572732f6167656e742e737667)](https://travis-ci.org/jenssegers/agent) [![Coverage Status](https://camo.githubusercontent.com/c43c6fbe00a271cf92f957f80891a6384d58964f5102ee1173831742a761a9d5/687474703a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6a656e737365676572732f6167656e742e737667)](https://coveralls.io/r/jenssegers/agent) [![Donate](https://camo.githubusercontent.com/d47cdb766a100070d38a702d9c7760ccc8052063484e1478a26bcd16680d33af/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d70617970616c2d626c75652e737667)](https://www.paypal.me/jenssegers)

A PHP desktop/mobile user agent parser with support for Laravel, based on [Mobile Detect](https://github.com/serbanghita/Mobile-Detect) with desktop support and additional functionality.

[![](https://camo.githubusercontent.com/1afdf5247fedfd04a69132c838ff76152e84a95f2c83b8c02ed08806449b3765/687474703a2f2f6a656e737365676572732e62652f75706c6f6164732f696d616765732f6167656e742e706e673f7634)](https://camo.githubusercontent.com/1afdf5247fedfd04a69132c838ff76152e84a95f2c83b8c02ed08806449b3765/687474703a2f2f6a656e737365676572732e62652f75706c6f6164732f696d616765732f6167656e742e706e673f7634)

Installation
------------

[](#installation)

Install using composer:

```
composer require jorisvanw/agent
```

Laravel (optional)
------------------

[](#laravel-optional)

Add the service provider in `app/config/app.php`:

```
'JorisvanW\Agent\AgentServiceProvider',
```

And add the Agent alias to `app/config/app.php`:

```
'Agent' => 'JorisvanW\Agent\Facades\Agent',
```

Basic Usage
-----------

[](#basic-usage)

Start by creating an `Agent` instance (or use the `Agent` Facade if you are using Laravel):

```
use JorisvanW\Agent\Agent;

$agent = new Agent();
```

If you want to parse user agents other than the current request in CLI scripts for example, you can use the `setUserAgent` and `setHttpHeaders` methods:

```
$agent->setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2');
$agent->setHttpHeaders($headers);
```

All of the original [Mobile Detect](https://github.com/serbanghita/Mobile-Detect) methods are still available, check out some original examples at

### Is?

[](#is)

Check for a certain property in the user agent.

```
$agent->is('Windows');
$agent->is('Firefox');
$agent->is('iPhone');
$agent->is('OS X');
```

### Magic is-method

[](#magic-is-method)

Magic method that does the same as the previous `is()` method:

```
$agent->isAndroidOS();
$agent->isNexus();
$agent->isSafari();
```

### Mobile detection

[](#mobile-detection)

Check for mobile device:

```
$agent->isMobile();
$agent->isTablet();
```

### Match user agent

[](#match-user-agent)

Search the user agent with a regular expression:

```
$agent->match('regexp');
```

Additional Functionality
------------------------

[](#additional-functionality)

### Accept languages

[](#accept-languages)

Get the browser's accept languages. Example:

```
$languages = $agent->languages();
// ['nl-nl', 'nl', 'en-us', 'en']
```

### Device name

[](#device-name)

Get the device name, if mobile. (iPhone, Nexus, AsusTablet, ...)

```
$device = $agent->device();
```

### Operating system name

[](#operating-system-name)

Get the operating system. (Ubuntu, Windows, OS X, ...)

```
$agent = $agent->platform();
```

### Browser name

[](#browser-name)

Get the browser name. (Chrome, IE, Safari, Firefox, ...)

```
$browser = $agent->browser();
```

### Desktop detection

[](#desktop-detection)

Check if the user is using a desktop device.

```
$agent->isDesktop();
```

*This checks if a user is not a mobile device, tablet or robot.*

### Phone detection

[](#phone-detection)

Check if the user is using a phone device.

```
$agent->isPhone();
```

### Robot detection

[](#robot-detection)

Check if the user is a robot.

```
$agent->isRobot();
```

### Robot name

[](#robot-name)

Get the robot name. Note: this currently only works for major robots like Google, Facebook, Twitter, Bing, Baidu etc ...

```
$robot = $agent->robot();
```

### Browser/platform version

[](#browserplatform-version)

MobileDetect recently added a `version` method that can get the version number for components. To get the browser or platform version you can use:

```
$browser = $agent->browser();
$version = $agent->version($browser);

$platform = $agent->platform();
$version = $agent->version($platform);
```

*Note, the version method is still in beta, so it might not return the correct result.*

License
-------

[](#license)

Laravel User Agent is licensed under [The MIT License (MIT)](LICENSE).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 78.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~73 days

Recently: every ~223 days

Total

23

Last Release

2920d ago

Major Versions

v1.0.0 → v2.0.02013-12-02

v2.3.0 → v3.0.02015-12-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/61791473a04a2f1535d7cb64d69b6d7f1d715535e64da8a62ec70b6370cdedbb?d=identicon)[JorisvanW](/maintainers/JorisvanW)

---

Top Contributors

[![jenssegers](https://avatars.githubusercontent.com/u/194377?v=4)](https://github.com/jenssegers "jenssegers (89 commits)")[![JorisvanW](https://avatars.githubusercontent.com/u/11089853?v=4)](https://github.com/JorisvanW "JorisvanW (17 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (3 commits)")[![KikoPalomares](https://avatars.githubusercontent.com/u/6002391?v=4)](https://github.com/KikoPalomares "KikoPalomares (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![jwpage](https://avatars.githubusercontent.com/u/52687?v=4)](https://github.com/jwpage "jwpage (1 commits)")[![jonathan-bird](https://avatars.githubusercontent.com/u/1510001?v=4)](https://github.com/jonathan-bird "jonathan-bird (1 commits)")[![dan-har](https://avatars.githubusercontent.com/u/8581476?v=4)](https://github.com/dan-har "dan-har (1 commits)")

---

Tags

browserlaraveluseragentmobileuser agentplatformAgent

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jorisvanw-agent/health.svg)

```
[![Health](https://phpackages.com/badges/jorisvanw-agent/health.svg)](https://phpackages.com/packages/jorisvanw-agent)
```

###  Alternatives

[jenssegers/agent

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

4.8k67.8M440](/packages/jenssegers-agent)[hisorange/browser-detect

Browser &amp; Mobile detection package for Laravel.

1.1k10.1M50](/packages/hisorange-browser-detect)[al-saloul/agent

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

1511.5k1](/packages/al-saloul-agent)[karmendra/laravel-agent-detector

Laravel wrapper for matomo-org/device-detector user agent parser

1241.6k](/packages/karmendra-laravel-agent-detector)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
