PHPackages                             soumen-dey/laravel-user-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. soumen-dey/laravel-user-agent

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

soumen-dey/laravel-user-agent
=============================

An advanced user agent detector for Laravel 5.5 and above.

v1.0(7y ago)35.6k1MITPHP

Since Jul 8Pushed 6y agoCompare

[ Source](https://github.com/soumen-dey/laravel-user-agent)[ Packagist](https://packagist.org/packages/soumen-dey/laravel-user-agent)[ Docs](https://github.com/soumen-dey/laravel-user-agent)[ RSS](/packages/soumen-dey-laravel-user-agent/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

laravel-user-agent
==================

[](#laravel-user-agent)

### An advanced user agent detector for Laravel 5.5 and above.

[](#an-advanced-user-agent-detector-for-laravel-55-and-above)

A powerful package allowing you to detect the user's Browser, Platform and more. This package provides a very simple API and requires no configurations at all.

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

[](#installation)

Via Composer

```
$ composer require soumen-dey/laravel-user-agent
```

**Note:** This package is tested and is fully compatible with Laravel 5.5 and above, not sure about support below Laravel 5.5.

If you are on Laravel 5.4 or below, you need to manually register the `ServiceProvider` and the `Alias`. In your `config/app.php` file just do:

```
'providers' => [
    // ...
    Soumen\Agent\AgentServiceProvider::class,
];

'aliases' => [
	//...
    'Agent' => Soumen\Agent\Facades\Agent::class,
];
```

For Laravel 5.5 and above, you don't need to do anything, just install the package and you are good to go!

Usage
-----

[](#usage)

- [Setup](#setup)
- [API](#api)
    - [The Facade](#the-agent-facade)
    - [Services](#services)
- [Fetching Properties](#fetching-properties)
    - [Properties as Parameter](#properties-as-parameter)
- [Browser](#browser)
- [Platform](#platform)
- [Device](#device)
- [User Agent](#user-agent)
- [Header](#header)
- [Server](#server)

### Setup

[](#setup)

If you have an alias set up for the `Agent` class, you don't need to import anything. However, if the alias is not set, you can do:

```
use Soumen\Agent\Agent;

// or

use Soumen\Agent\Facades\Agent
```

You are now ready to use the package.

### API

[](#api)

#### The `Agent` Facade

[](#the-agent-facade)

You can access the visitor's details such as the browser using:

```
Agent::browser(); // returns all the details related to the visitor's browser
```

Likewise you can also fetch other details:

```
Agent::ip(); // the ip address of the visitor
Agent::device(); // details related to the visitor's device, eg, Phone, Tablet, etc.
Agent::header(); // details related to the request's header
Agent::platform(); // details related to the platform of the visitor, eg. Windows, etc.
Agent::userAgent(); // returns the HTTP_USER_AGENT string
```

You can also fetch server related info:

```
Agent::server(); // returns details related to the server
```

#### Available Methods

[](#available-methods)

Methods`Agent::ip()`Returns the visitor's `ip` address.`Agent::all()`Returns all the details about the visitor.`Agent::get()`Same as the `all()` method.`Agent::header()`Get information related to the request's header.`Agent::server()`Get information related to the applications's server.`Agent::device()`Get information related to the visitor's device, eg. Apple, Samsung, Mobile, Tablet, etc.`Agent::browser()`Get information related to the visitor's browser.`Agent::platform()`Get information related to the visitor's platform, eg. Windows, Mac, etc.`Agent::userAgent()`Returns the `HTTP_USER_AGENT` string.You can also retrieve properties:

```
Agent::browser('name'); // Firefox 61
Agent::browser()->name; // Firefox 61
Agent::browser()->getName(); // Firefox 61
```

Individual services handles the task of fetching visitor information, for more information read the [Services](#services) section.

To get individual service:

```
$browser = Agent::get('browser'); // returns the browser service
$browser = Agent::browser(); // same as above
```

### Services

[](#services)

The `Agnet` facade is a global wrapper for individual services that handles the actual task of fetching information about the visitor. You can call the Services directly if you want to be more specific.

Get details about the visitor's browser for example:

```
use Soumen\Agent\Services\Browser;

Browser::get(); // returns all details related to the visitor's browser
Browser::getDetails(); // same as get() method
```

The API for every service is similar except for some minor changes, so you can do:

```
use Soumen\Agnet\Services\Device;
use Soumen\Agent\Services\Platform;

$device = Device::get(); // get details about the visitor's device
$platform = Platform::get(); // get details related to the visitor's platform
```

### Available Services

[](#available-services)

ServiceNamespaceUsage[`Browser`](#browser)`Soumen\Agent\Services\Browser``Browser::get()`,
`Browser::getDetails()`Returns all the information related to the visitor's browser[`Platform`](#platform)`Soumen\Agent\Services\Platform``Platform::get()`,
`Platform::getDetails()`Returns all the information related to the visitor's platform, eg. Windows, Mac, etc.[`Device`](#device)`Soumen\Agent\Services\Device``Device::get()`,
`Device::getDetails()`Returns all the information related to the visitor's device, eg, Mobile or Tablet, Name, etc.[`UserAgent`](#user-agent)`Soumen\Agent\Services\UserAgnet``UserAgent::get()`,
`UserAgent::getDetails()`Returns the visitor's `HTTP_USER_AGENT` string[`Header`](#header)`Soumen\Agent\Services\Header``Header::get()`,
`Header::getDetails()`Returns all information related to the request's `header`[`Server`](#server)`Soumen\Agent\Services\Server``Server::get()`,
`Server::getDetails()`Returns information about the application's server.### Fetching Properties

[](#fetching-properties)

To get individual browser property such as `name` do one of the following:

```
$browser = Agent::browser('name');
$browser = Agent::browser()->name;
$browser = Agent::browser()->name();
$browser = Agent::browser()->getName();
```

Using the Service:

```
use Soumen\Agent\Services\Browser;

// get the name of the browser
$browser = Browser::get('name');
$browser = Browser::get()->name;
$browser = Browser::get()->name();
$browser = Browser::get()->getName();

// or

$browser = Browser::getDetails('name');
$browser = Browser::getDetails()->name;
...
// You get the idea
```

This applies to all the available properties of the browser. Refer to the section for each service for more information.

#### Properties as parameter

[](#properties-as-parameter)

You can use the property name as the parameter, so you can do:

```
Agent::browser('name'); // Firefox 61
Agent::platform('name'); // Windows 10
```

Instead of:

```
Agent::browser()->name;
Agent::platform()->name;
```

Using individual service:

```
use Soumen\Agent\Services\Browser;
use Soumen\Agent\Services\Platform;

Browser::get('name'); // Firefox 61
Platform::get('name'); // Windows 10

// or

Browser::getDetails('name'); // Firefox 61
Platform::getDetails('name'); // Windows 10
```

**Note:** The parameter should be the ***exact*** same string as the property name.

For a list of available properties, refer to the **Properties** section of the respective **Service**

### Browser

[](#browser)

Using the Facade:

```
$browser = Agent::browser();
```

Using the Service:

```
use Soumen\Agent\Services\Browser;

$browser = Browser::get();

// or

$browser = Browser::getDetails();
```

##### Available Properties:

[](#available-properties)

PropertiesMethods`$browser->name``$browser->name()`,
 `$browser->getName()`Returns the name of the browser.`$browser->version``$browser->version()`,
 `$browser->getVersion()`Returns the browser's version number.`$browser->versionMajor``$browser->versionMajor()`,
 `$browser->getVersionMajor()`Returns the browser's semantic major version number.`$browser->versionMinor``$browser->versionMinor()`,
 `$browser->getVersionMinor()`Returns the browser's semantic minor version number.`$browser->versionPatch``$browser->versionPatch()`,
 `$browser->getVersionPatch()`Returns the browser's semantic patch version.`$browser->engine``$browser->engine()`,
 `$browser->getEngine()`Returns the browser's rendering engine.`$browser->family``$browser->family()`,
 `$browser->getFamily()`,
 `$browser->getVendor()`Returns the browser's vendor. Eg. Chrome, Firefox, etc.### Platform

[](#platform)

Using the Facade:

```
$platform = Agent::platform();
```

Using the Service:

```
use Soumen\Agent\Services\Platform;

$platform = Platform::get();

// or

$platform = Platform::getDetails();
```

##### Available Properties:

[](#available-properties-1)

PropertiesMethods`$platform->name``$platform->name()`,
 `$platform->getName()`Returns the name of the Operating System.`$platform->family``$platform->family()`,
 `$platform->getFamily()`,
 `$platform->getVendor()`Returns the Operating System's vendor. Eg. Windows, Mac, Linux, etc.`$platform->version``$platform->version()`,
 `$platform->getVersion()`Returns the Operating System's human friendly version eg. XP, Vista, etc.`$platform->versionMajor``$platform->versionMajor()`,
 `$platform->getVersionMajor()`Returns the Operating System's semantic major version number.`$platform->versionMinor``$platform->versionMinor()`,
 `$platform->getVersionMinor()`Returns the Operating System's semantic minor version number.`$platform->versionPatch``$platform->versionPatch()`,
 `$platform->getVersionPatch()`Returns the Operating System's semantic patch version.### Device

[](#device)

Using the Facade:

```
$device = Agent::device();
```

Using the Service:

```
use Soumen\Agent\Services\Device;

$device = Device::get();

// or

$device = Device::getDetails();
```

##### Available Properties:

[](#available-properties-2)

PropertiesMethods`$device->family``$device->family()`,
 `$device->getFamily()`,
 `$device->getVendor()`Returns the device's vendor like Samsung, Apple, Huawei.`$device->model``$device->model()`,
 `$device->getModel()`Returns the device's brand name like iPad, iPhone, Nexus.`$device->mobileGrade``$device->mobileGrade()`,
 `$device->getMobileGrade()`Returns the device's mobile grade in scale of A,B,C for performance.`$device->isMobile``$device->isMobile()`
 `$device->getIsMobile()`Determines if the device is a mobile device, returns boolean.`$device->isTablet``$device->isTablet()`
 `$device->getIsTablet()`Determines if the device is a tablet device, returns boolean.`$device->isDesktop``$device->isDesktop()`
 `$device->getIsDesktop()`Determines if the device is a desktop computer, returns boolean.`$device->isBot``$device->isBot()`
 `$device->getIsBot()`Determines if the device is a crawler / bot, returns boolean`$device->getType() `Returns the type of device eg. mobile, tablet, etc.### User Agent

[](#user-agent)

Using the Facade:

```
$userAgent = Agent::userAgent();
```

Using the Service:

```
use Soumen\Agent\Services\UserAgent;

$userAgent = UserAgent::get();
```

No specific properties for this service.

### Header

[](#header)

Using the Facade:

```
$header = Agent::header();
```

Using the Service:

```
use Soumen\Agent\Service\Header;

$header = Header::get();

// or

$header = Header::getDetails();
```

#### Available Properties

[](#available-properties-3)

PropertiesMethodsParameters`$header->host`,
`$header->host`,
`$header->host()`,
`$header->host()`,
`$header->getHost()``host``$header->userAgent`,
`$header->user_agent`,
`$header->userAgent()`,
`$header->user_agent()`,
`$header->getUserAgent()``user-agent``$header->accept`,
`$header->accept`,
`$header->accept()`,
`$header->accept()`,
`$header->getAccept()``accept``$header->acceptLanguage`,
`$header->accept_language`,
`$header->acceptLanguage()`,
`$header->accept_language()`,
`$header->getAcceptLanguage()``accept-language``$header->acceptEncoding`,
`$header->accept_encoding`,
`$header->acceptEncoding()`,
`$header->accept_encoding()`,
`$header->getAcceptEncoding()``accept-encoding``$header->cookie`,
`$header->cookie`,
`$header->cookie()`,
`$header->cookie()`,
`$header->getCookie()``cookie``$header->connection`,
`$header->connection`,
`$header->connection()`,
`$header->connection()`,
`$header->getConnection()``connection``$header->upgradeInsecureRequests`,
`$header->upgrade_insecure_requests`,
`$header->upgradeInsecureRequests()`,
`$header->upgrade_insecure_requests()`,
`$header->getUpgradeInsecureRequests()``upgrade-insecure-requests``$header->cacheControl`,
`$header->cache_control`,
`$header->cacheControl()`,
`$header->cache_control()`,
`$header->getCacheControl()``cache-control`You can use the property names as the string in the *parameter* column:

```
Header::get('user-agent');
Agent::header('user-agent');
```

### Server

[](#server)

Using the Facade:

```
$server = Agent::server();
```

Using the Service:

```
use Soumen\Agent\Services\Server;

$server = Server::get();

// or

$server = Server::getDetails();
```

#### Available Properties

[](#available-properties-4)

PropertiesMethods`$server->DOCUMENT_ROOT`,
`$server->documentRoot``$server->DOCUMENT_ROOT()`,
`$server->documentRoot()`,
`$server->getDocumentRoot()`Returns the value of PHP's `$_SERVER['DOCUMENT_ROOT']` superglobal.`$server->REMOTE_ADDR`,
`$server->remoteAddr``$server->REMOTE_ADDR()`,
`$server->remoteAddr()`,
`$server->getRemoteAddr()`Returns the value of PHP's `$_SERVER['REMOTE_ADDR']` superglobal.`$server->REMOTE_PORT`,
`$server->remotePort``$server->REMOTE_PORT()`,
`$server->remotePort()`,
`$server->getRemotePort()`Returns the value of PHP's `$_SERVER['REMOTE_PORT']` superglobal.`$server->SERVER_SOFTWARE`,
`$server->serverSoftware``$server->SERVER_SOFTWARE()`,
`$server->serverSoftware()`,
`$server->getServerSoftware()`Returns the value of PHP's `$_SERVER['SERVER_SOFTWARE']` superglobal.`$server->SERVER_PROTOCOL`,
`$server->serverProtocol``$server->SERVER_PROTOCOL()`,
`$server->serverProtocol()`,
`$server->getServerProtocol()`Returns the value of PHP's `$_SERVER['SERVER_PROTOCOL']` superglobal.`$server->SERVER_NAME`,
`$server->serverName``$server->SERVER_NAME()`,
`$server->serverName()`,
`$server->getServerName()`Returns the value of PHP's `$_SERVER['SERVER_NAME']` superglobal.`$server->SERVER_PORT`,
`$server->serverPort``$server->SERVER_PORT()`,
`$server->serverPort()`,
`$server->getServerPort()`Returns the value of PHP's `$_SERVER['SERVER_PORT']` superglobal.`$server->REQUEST_URI`,
`$server->requestUri``$server->REQUEST_URI()`,
`$server->requestUri()`,
`$server->getRequestUri()`Returns the value of PHP's `$_SERVER['REQUEST_URI']` superglobal.`$server->REQUEST_METHOD`,
`$server->requestMethod``$server->REQUEST_METHOD()`,
`$server->requestMethod()`,
`$server->getRequestMethod()`Returns the value of PHP's `$_SERVER['REQUEST_METHOD']` superglobal.`$server->SCRIPT_NAME`,
`$server->scriptName``$server->SCRIPT_NAME()`,
`$server->scriptName()`,
`$server->getScriptName()`Returns the value of PHP's `$_SERVER['SCRIPT_NAME']` superglobal.`$server->SCRIPT_FILENAME`,
`$server->scriptFilename``$server->SCRIPT_FILENAME()`,
`$server->scriptFilename()`,
`$server->getScriptFilename()`Returns the value of PHP's `$_SERVER['SCRIPT_FILENAME']` superglobal.`$server->PATH_INFO`,
`$server->pathInfo``$server->PATH_INFO()`,
`$server->pathInfo()`,
`$server->getPathInfo()`Returns the value of PHP's `$_SERVER['PATH_INFO']` superglobal.`$server->PHP_SELF`,
`$server->phpSelf``$server->PHP_SELF()`,
`$server->phpSelf()`,
`$server->getPhpSelf()`Returns the value of PHP's `$_SERVER['PHP_SELF']` superglobal.`$server->HTTP_HOST`,
`$server->httpHost``$server->HTTP_HOST()`,
`$server->httpHost()`,
`$server->getHttpHost()`Returns the value of PHP's `$_SERVER['HTTP_HOST']` superglobal.`$server->HTTP_USER_AGENT`,
`$server->httpUserAgent``$server->HTTP_USER_AGENT()`,
`$server->httpUserAgent()`,
`$server->getHttpUserAgent()`Returns the value of PHP's `$_SERVER['HTTP_USER_AGENT']` superglobal.`$server->HTTP_ACCEPT`,
`$server->httpAccept``$server->HTTP_ACCEPT()`,
`$server->httpAccept()`,
`$server->getHttpAccept()`Returns the value of PHP's `$_SERVER['HTTP_ACCEPT']` superglobal.`$server->HTTP_ACCEPT_LANGUAGE`,
`$server->httpAcceptLanguage``$server->HTTP_ACCEPT_LANGUAGE()`,
`$server->httpAcceptLanguage()`,
`$server->getHttpAcceptLanguage()`Returns the value of PHP's `$_SERVER['HTTP_ACCEPT_LANGUAGE']` superglobal.`$server->HTTP_ACCEPT_ENCODING`,
`$server->httpAcceptEncoding``$server->HTTP_ACCEPT_ENCODING()`,
`$server->httpAcceptEncoding()`,
`$server->getHttpAcceptEncoding()`Returns the value of PHP's `$_SERVER['HTTP_ACCEPT_ENCODING']` superglobal.`$server->HTTP_COOKIE`,
`$server->httpCookie``$server->HTTP_COOKIE()`,
`$server->httpCookie()`,
`$server->getHttpCookie()`Returns the value of PHP's `$_SERVER['HTTP_COOKIE']` superglobal.`$server->HTTP_CONNECTION`,
`$server->httpConnection``$server->HTTP_CONNECTION()`,
`$server->httpConnection()`,
`$server->getHttpConnection()`Returns the value of PHP's `$_SERVER['HTTP_CONNECTION']` superglobal.`$server->HTTP_UPGRADE_INSECURE_REQUESTS`,
`$server->httpUpgradeInsecureRequests``$server->HTTP_UPGRADE_INSECURE_REQUESTS()`,
`$server->httpUpgradeInsecureRequests()`,
`$server->getHttpUpgradeInsecureRequests()`Returns the value of PHP's `$_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS']` superglobal.`$server->HTTP_CACHE_CONTROL`,
`$server->httpCacheControl``$server->HTTP_CACHE_CONTROL()`,
`$server->httpCacheControl()`,
`$server->getHttpCacheControl()`Returns the value of PHP's `$_SERVER['HTTP_CACHE_CONTROL']` superglobal.`$server->REQUEST_TIME_FLOAT`,
`$server->requestTimeFloat``$server->REQUEST_TIME_FLOAT()`,
`$server->requestTimeFloat()`,
`$server->getRequestTimeFloat()`Returns the value of PHP's `$_SERVER['REQUEST_TIME_FLOAT']` superglobal.`$server->REQUEST_TIME`,
`$server->requestTime``$server->REQUEST_TIME()`,
`$server->requestTime()`,
`$server->getRequestTime()`Returns the value of PHP's `$_SERVER['REQUEST_TIME']` superglobal.Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email me at .

Credits
-------

[](#credits)

- [Soumen Dey](https://github.com/soumen-dey)
- [All Contributors](../../contributors%5D)
- A big thanks to hisorange/browser-detect.

License
-------

[](#license)

This package is released under the MIT License (MIT). Please see the [license file](license.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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

Unknown

Total

1

Last Release

2866d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7effb84954b7c7702168f01f78b791319ed5c7557329d43818837d127ec2da48?d=identicon)[soumen-dey](/maintainers/soumen-dey)

---

Top Contributors

[![soumen-dey](https://avatars.githubusercontent.com/u/27819155?v=4)](https://github.com/soumen-dey "soumen-dey (1 commits)")

---

Tags

laraveluseragentuser agentdevice detectdevice detectorbrowser-detectorbrowser detect

### Embed Badge

![Health badge](/badges/soumen-dey-laravel-user-agent/health.svg)

```
[![Health](https://phpackages.com/badges/soumen-dey-laravel-user-agent/health.svg)](https://phpackages.com/packages/soumen-dey-laravel-user-agent)
```

###  Alternatives

[jenssegers/agent

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

4.8k67.8M440](/packages/jenssegers-agent)[propa/laravel-browscap

Browscap-PHP integration for Laravel 5-12

1060.3k](/packages/propa-laravel-browscap)[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)
