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

ActiveLibrary

spinzar/laravel-agent
=====================

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

00PHP

Since Jun 2Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Agent
=============

[](#laravel-agent)

The \[Agent\] package seems to be incompatible with Laravel 11. Let's move forward with a different approach to achieve the desired functionality.
--------------------------------------------------------------------------------------------------------------------------------------------------

[](#the-agent-package-seems-to-be-incompatible-with-laravel-11-lets-move-forward-with-a-different-approach-to-achieve-the-desired-functionality)

Warning: This package is for \[demonstration purposes / personal learning only\]. Use at your own risk! It may have bugs or functionalities not suitable for production.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#warning-this-package-is-for-demonstration-purposes--personal-learning-only-use-at-your-own-risk-it-may-have-bugs-or-functionalities-not-suitable-for-production)

In Laravel versions below 11, you'll need to use **[Agent](https://github.com/jenssegers/agent)** recommended.
--------------------------------------------------------------------------------------------------------------

[](#in-laravel-versions-below-11-youll-need-to-use-agent-recommended)

Laravel Agent acts as a bridge between your Laravel application and the user's device,
--------------------------------------------------------------------------------------

[](#laravel-agent-acts-as-a-bridge-between-your-laravel-application-and-the-users-device)

allowing you to make informed decisions about how to present your content and interact with your users
------------------------------------------------------------------------------------------------------

[](#allowing-you-to-make-informed-decisions-about-how-to-present-your-content-and-interact-with-your-users)

based on the device they're using. This results in a more tailored and user-friendly experience for everyone.
-------------------------------------------------------------------------------------------------------------

[](#based-on-the-device-theyre-using-this-results-in-a-more-tailored-and-user-friendly-experience-for-everyone)

Focusing on Functionality:
--------------------------

[](#focusing-on-functionality)

- "Another package relies on the features provided by package-name above. We need to ensure it's included as a dependency."

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

[](#installation)

Install using composer:

```
composer require spinzar/laravel-agent
```

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

[](#laravel-optional)

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

```
Spinzar\LaravelAgent\AgentServiceProvider::class,
```

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

```
'LaravelAgent' => Spinzar\LaravelAgent\Facades\LaravelAgent::class,
```

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

[](#basic-usage)

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

```
use Spinzar\LaravelAgent\LaravelAgent;

$larvaelagent = new LaravelAgent();
```

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:

```
$larvaelagent->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');
$larvaelagent->setHttpHeaders($headers);
```

### Is?

[](#is)

Check for a certain property in the user agent.

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

### Magic is-method

[](#magic-is-method)

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

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

### Mobile detection

[](#mobile-detection)

Check for mobile device:

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

### Match user agent

[](#match-user-agent)

Search the user agent with a regular expression:

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

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

[](#additional-functionality)

### Accept languages

[](#accept-languages)

Get the browser's accept languages. Example:

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

### Device name

[](#device-name)

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

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

### Operating system name

[](#operating-system-name)

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

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

### Browser name

[](#browser-name)

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

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

### Desktop detection

[](#desktop-detection)

Check if the user is using a desktop device.

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

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

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

### Robot name

[](#robot-name)

Get the robot name.

```
$robot = $larvaelagent->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 = $larvaelagent->browser();
$version = $larvaelagent->version($browser);

$platform = $larvaelagent->platform();
$version = $larvaelagent->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

13

—

LowBetter than 1% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/987ff229c44a1c7100e95f77e4bc07c911f99ff9f270bbcf7b9b4bac0318635f?d=identicon)[spinzar](/maintainers/spinzar)

---

Top Contributors

[![spinzar](https://avatars.githubusercontent.com/u/73431676?v=4)](https://github.com/spinzar "spinzar (3 commits)")

### Embed Badge

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

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

PHPackages © 2026

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