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

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

asika/agent
===========

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

2.7.3(2mo ago)164.9k↑12.8%42MITPHPPHP &gt;=8.0CI passing

Since Jan 29Pushed 2mo agoCompare

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

READMEChangelogDependencies (4)Versions (3)Used By (2)

Agent
=====

[](#agent)

[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/b1cf92518811f173733e5fd1b428efcb549cfcde02f7160018dc5f61f43d925d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6173696b6133323736342f6167656e742f63692e796d6c3f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/b1cf92518811f173733e5fd1b428efcb549cfcde02f7160018dc5f61f43d925d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6173696b6133323736342f6167656e742f63692e796d6c3f7374796c653d666f722d7468652d6261646765)[![Packagist Version](https://camo.githubusercontent.com/b706fd829e4ea30748677d2a58e5c2e1cb4996b1d8a5d62b1c43deda667e2cb5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6173696b612f6167656e743f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/asika/agent)[![Packagist Downloads](https://camo.githubusercontent.com/dfa7f533f97f7d19694c0d391d803bf21a1feea65ddea2fad4441decf8be150d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6173696b612f6167656e743f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/asika/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.

Note

This is a modified version of [jenssegers/agent](https://github.com/jenssegers/agent) to support PHP 8.0 up and MobileDetect 4.x.

Important

This fork is for B/C purpose. If you need a long-term support, please try

-
-

[![](https://camo.githubusercontent.com/e337eb79fd5eeb1b08baa5c4e6febccc56845dcf09c17484e2b81dcfb5bfced8/68747470733a2f2f6a656e737365676572732e636f6d2f7374617469632f6d656469612f6167656e742e706e67)](https://camo.githubusercontent.com/e337eb79fd5eeb1b08baa5c4e6febccc56845dcf09c17484e2b81dcfb5bfced8/68747470733a2f2f6a656e737365676572732e636f6d2f7374617469632f6d656469612f6167656e742e706e67)

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

[](#installation)

Install using composer:

```
composer require asika/agent
```

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

[](#laravel-optional)

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

```
Asika\Agent\AgentServiceProvider::class,
```

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

```
'Agent' => Asika\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 Asika\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('macOS');
```

### 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).

Security contact information
----------------------------

[](#security-contact-information)

To report a security vulnerability, follow [these steps](https://tidelift.com/security).

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance86

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community27

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.4% 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 ~450 days

Total

2

Last Release

70d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1639206?v=4)[Simon Asika](/maintainers/asika32764)[@asika32764](https://github.com/asika32764)

---

Top Contributors

[![jenssegers](https://avatars.githubusercontent.com/u/194377?v=4)](https://github.com/jenssegers "jenssegers (155 commits)")[![asika32764](https://avatars.githubusercontent.com/u/1639206?v=4)](https://github.com/asika32764 "asika32764 (15 commits)")[![Skaronator](https://avatars.githubusercontent.com/u/2886913?v=4)](https://github.com/Skaronator "Skaronator (5 commits)")[![mpetty](https://avatars.githubusercontent.com/u/1807888?v=4)](https://github.com/mpetty "mpetty (4 commits)")[![ElfSundae](https://avatars.githubusercontent.com/u/526008?v=4)](https://github.com/ElfSundae "ElfSundae (3 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (3 commits)")[![ThaDafinser](https://avatars.githubusercontent.com/u/533017?v=4)](https://github.com/ThaDafinser "ThaDafinser (3 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (3 commits)")[![JayBizzle](https://avatars.githubusercontent.com/u/340752?v=4)](https://github.com/JayBizzle "JayBizzle (3 commits)")[![jwpage](https://avatars.githubusercontent.com/u/52687?v=4)](https://github.com/jwpage "jwpage (2 commits)")[![loclv](https://avatars.githubusercontent.com/u/6302717?v=4)](https://github.com/loclv "loclv (2 commits)")[![sebastiaanspeck](https://avatars.githubusercontent.com/u/12570668?v=4)](https://github.com/sebastiaanspeck "sebastiaanspeck (2 commits)")[![BertKooij](https://avatars.githubusercontent.com/u/3949189?v=4)](https://github.com/BertKooij "BertKooij (2 commits)")[![yaoshanliang](https://avatars.githubusercontent.com/u/5028569?v=4)](https://github.com/yaoshanliang "yaoshanliang (1 commits)")[![CaddyDz](https://avatars.githubusercontent.com/u/13698160?v=4)](https://github.com/CaddyDz "CaddyDz (1 commits)")[![dan-har](https://avatars.githubusercontent.com/u/8581476?v=4)](https://github.com/dan-har "dan-har (1 commits)")[![doggieliu](https://avatars.githubusercontent.com/u/66601667?v=4)](https://github.com/doggieliu "doggieliu (1 commits)")[![evrard-c](https://avatars.githubusercontent.com/u/23173851?v=4)](https://github.com/evrard-c "evrard-c (1 commits)")[![francislavoie](https://avatars.githubusercontent.com/u/2111701?v=4)](https://github.com/francislavoie "francislavoie (1 commits)")[![jonathan-bird](https://avatars.githubusercontent.com/u/1510001?v=4)](https://github.com/jonathan-bird "jonathan-bird (1 commits)")

---

Tags

accept-languagebrowsermobile-detectplatformrobotuser-agentbrowserlaraveluseragentmobileuser agentplatformdesktopAgent

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[jenssegers/agent

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

4.8k72.3M513](/packages/jenssegers-agent)[hisorange/browser-detect

Browser &amp; Mobile detection package for Laravel.

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

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

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

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

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

PHPackages © 2026

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