PHPackages                             luozhenyu/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. luozhenyu/agent

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

luozhenyu/agent
===============

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

v1.4(7y ago)045MITPHPPHP &gt;=5.6

Since Aug 15Pushed 7y ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (6)Used By (0)

Agent
=====

[](#agent)

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.

It is forked from [jenssegers/agent](https://github.com/jenssegers/agent). Thanks to his great work.

The project is more powerful and contains more devices and browsers in China.

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

[](#installation)

Install using composer:

```
composer require luozhenyu/agent
```

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

[](#laravel-optional)

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

```
Luozhenyu\Agent\AgentServiceProvider::class,
```

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

```
'Agent' => Luozhenyu\Agent\Facades\Agent::class,
```

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

[](#basic-usage)

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

```
use Luozhenyu\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, ...)

```
$platform = $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. This uses [jaybizzle/crawler-detect](https://github.com/JayBizzle/Crawler-Detect) to do the actual robot detection.

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

### Robot name

[](#robot-name)

Get the robot name.

```
$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

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

5

Last Release

2876d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16633830?v=4)[罗震宇](/maintainers/luozhenyu)[@luozhenyu](https://github.com/luozhenyu)

---

Top Contributors

[![luozhenyu](https://avatars.githubusercontent.com/u/16633830?v=4)](https://github.com/luozhenyu "luozhenyu (1 commits)")

---

Tags

browserlaraveluseragentmobileuser agentplatformdesktopAgent

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[jenssegers/agent

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

4.8k70.8M496](/packages/jenssegers-agent)[hisorange/browser-detect

Browser &amp; Mobile detection package for Laravel.

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

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

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

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

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

PHPackages © 2026

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