PHPackages                             pataar/browser-detect - 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. pataar/browser-detect

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

pataar/browser-detect
=====================

Browser &amp; Mobile detection package for Laravel.

5.4.0(1mo ago)63.2k2MITPHPPHP ^8.3CI passing

Since Nov 13Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/pataar/browser-detect)[ Packagist](https://packagist.org/packages/pataar/browser-detect)[ Docs](https://github.com/pataar/browser-detect)[ RSS](/packages/pataar-browser-detect/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (5)Dependencies (12)Versions (63)Used By (0)

Browser Detect
==============

[](#browser-detect)

[![Latest Stable Version](https://camo.githubusercontent.com/a59f2d6f69158712ac60a9cbb04b6ac2a145e0e43ec573bdeab9629248ba55fd/68747470733a2f2f706f7365722e707567782e6f72672f7061746161722f62726f777365722d6465746563742f762f737461626c65)](https://packagist.org/packages/pataar/browser-detect)[![Build](https://github.com/pataar/browser-detect/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/pataar/browser-detect/actions/workflows/tests.yml)[![PHPStan](https://github.com/pataar/browser-detect/actions/workflows/static-analysis.yml/badge.svg?branch=main)](https://github.com/pataar/browser-detect/actions/workflows/static-analysis.yml)[![Coverage Status](https://camo.githubusercontent.com/860016ee80e305168abfdbb2e3f51bfcc901a19672a5343451b54bb77955dd8a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7061746161722f62726f777365722d6465746563742f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/pataar/browser-detect?branch=main)[![Total Downloads](https://camo.githubusercontent.com/64a47087ea815924141716c76779de33495f92d2c89f8fe4aaab825a6de90b19/68747470733a2f2f706f7365722e707567782e6f72672f7061746161722f62726f777365722d6465746563742f646f776e6c6f616473)](https://packagist.org/packages/pataar/browser-detect)[![License](https://camo.githubusercontent.com/dfe3562e4503499b6a22ea885d416870e866bed58ccacd0d73419417c4739391/68747470733a2f2f706f7365722e707567782e6f72672f7061746161722f62726f777365722d6465746563742f6c6963656e7365)](https://packagist.org/packages/pataar/browser-detect)

A Laravel package to identify the visitor's browser, operating system, and device type. Results are powered by two well-tested detection libraries — no magic involved.

> **Fork notice:** This is a maintained fork of [hisorange/browser-detect](https://github.com/hisorange/browser-detect) by [Varga Zsolt](https://github.com/hisorange), which appears to be abandoned. Full credit to the original author for the design and initial implementation.

### Changes from the original

[](#changes-from-the-original)

- PHP 8.3+ and Laravel 11–13 support (dropped older versions)
- Removed `ua-parser/ua-parser` and `mobiledetect/mobiledetect` — detection is now powered by fewer, better-maintained libraries

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 11, 12, or 13 (or standalone without Laravel)

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

[](#installation)

```
composer require pataar/browser-detect
```

That's it — Laravel auto-discovers the service provider and facade.

Usage
-----

[](#usage)

### Facade

[](#facade)

```
use Browser;

if (Browser::isMobile()) {
    // Redirect to the mobile version of the site.
}

if (Browser::isBot()) {
    echo 'Bot detected!';
}

if (Browser::isFirefox() || Browser::isOpera()) {
    $response .= '';
}

if (Browser::isAndroid()) {
    $response .= 'Install our Android App!';
} elseif (Browser::isMac() && Browser::isMobile()) {
    $response .= 'Install our iOS App!';
}
```

### Blade directives

[](#blade-directives)

```
@mobile
    This is the MOBILE template!
    @include('your-mobile-template')
@endmobile

@tablet
    This is the TABLET template!
@endtablet

@desktop
    This is the DESKTOP template!
@enddesktop

@browser('isBot')
    Bots are identified too!
@endbrowser
```

### Standalone (without Laravel)

[](#standalone-without-laravel)

```
use hisorange\BrowserDetect\Parser as Browser;

if (Browser::isLinux()) {
    // Works without Laravel!
}
```

### Parsing a specific user agent

[](#parsing-a-specific-user-agent)

```
$result = Browser::detect();       // Current visitor
$result = Browser::parse('Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14');
```

Results are cached in memory for the current request and optionally persisted via Laravel's cache (7-day TTL by default).

API Reference
-------------

[](#api-reference)

### Device detection

[](#device-detection)

MethodReturnsDescription`Browser::isMobile()``bool`Is this a mobile device?`Browser::isTablet()``bool`Is this a tablet device?`Browser::isDesktop()``bool`Is this a desktop computer?`Browser::isBot()``bool`Is this a crawler / bot?`Browser::deviceType()``string`One of: `Mobile`, `Tablet`, `Desktop`, `Bot``Browser::deviceFamily()``string`Device vendor (Samsung, Apple, Huawei, ...)`Browser::deviceModel()``string`Device model (iPad, iPhone, Nexus, ...)### Browser detection

[](#browser-detection)

MethodReturnsDescription`Browser::browserName()``string`Human-friendly name (e.g. `Firefox 3.6`)`Browser::browserFamily()``string`Vendor (Chrome, Firefox, Opera, ...)`Browser::browserVersion()``string`Version string with trailing `.0` trimmed`Browser::browserVersionMajor()``int`Semantic major version`Browser::browserVersionMinor()``int`Semantic minor version`Browser::browserVersionPatch()``int`Semantic patch version`Browser::browserEngine()``string`Rendering engine (Blink, WebKit, Gecko, ...)`Browser::isChrome()``bool`Chrome or Chromium?`Browser::isFirefox()``bool`Firefox?`Browser::isOpera()``bool`Opera?`Browser::isSafari()``bool`Safari?`Browser::isEdge()``bool`Microsoft Edge?`Browser::isIE()``bool`Internet Explorer (or Trident)?`Browser::isIEVersion(int, op)``bool`Compare against a specific IE version`Browser::isInApp()``bool`In-app browser (WebView, Twitter, WeChat)?### Operating system detection

[](#operating-system-detection)

MethodReturnsDescription`Browser::platformName()``string`Human-friendly name (e.g. `Windows 10`)`Browser::platformFamily()``string`Vendor (Linux, Windows, Mac, ...)`Browser::platformVersion()``string`Version string with trailing `.0` trimmed`Browser::platformVersionMajor()``int`Semantic major version`Browser::platformVersionMinor()``int`Semantic minor version`Browser::platformVersionPatch()``int`Semantic patch version`Browser::isWindows()``bool`Windows?`Browser::isLinux()``bool`Linux?`Browser::isMac()``bool`macOS or iOS?`Browser::isAndroid()``bool`Android?Configuration
-------------

[](#configuration)

In Laravel, publish the config file:

```
php artisan vendor:publish --provider="hisorange\BrowserDetect\ServiceProvider"
```

In standalone mode, pass a custom config array:

```
use hisorange\BrowserDetect\Parser;

$browser = new Parser(null, null, [
    'cache' => [
        'interval' => 86400, // Cache TTL in seconds
    ],
]);
```

Available options:

KeyDefaultDescription`cache.interval``10080`Cache TTL in seconds`cache.prefix``bd4_`Cache key prefix`cache.device-detector``null`Cache driver for device-detector's internal cache. See `config/browser-detect.php` for examples.`security.max-header-length``2048`Max user agent length (DoS protection)Quality
-------

[](#quality)

This package aims for 100% test coverage and PHPStan level `max` with zero baseline errors.

Credits
-------

[](#credits)

This package was originally created by [Varga Zsolt (hisorange)](https://github.com/hisorange). This fork is maintained by [Pieter Willekens (pataar)](https://github.com/pataar).

Detection is powered by:

- [jaybizzle/crawler-detect](https://github.com/JayBizzle/Crawler-Detect) — Bot and crawler detection
- [matomo/device-detector](https://github.com/matomo-org/device-detector) — Comprehensive device, browser, and OS parsing

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance90

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 57.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 ~108 days

Recently: every ~12 days

Total

43

Last Release

48d ago

Major Versions

3.1.4 → 4.0.02019-11-13

3.1.5 → 4.2.02020-02-27

3.1.6 → 4.4.02021-02-23

4.5.4 → 5.0.02023-09-22

5.3.1 → 6.x-dev2026-03-20

PHP version history (9 changes)0.9.1PHP &gt;=5.3.0

1.0.1PHP &gt;=5.4.0

3.0.0PHP &gt;=5.6.0

4.0.0PHP &gt;=7.1.0

4.2.2PHP ^7.1

4.3.0PHP &gt;=7.2

4.4.0PHP ^7.2 || ^8.0

5.0.0PHP ^8.1

5.1.2PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/acb1dc902f11f870ae9da0d73c77b0200ada996101bf6830c9199d79c7a56be6?d=identicon)[pataar](/maintainers/pataar)

---

Top Contributors

[![hisorange](https://avatars.githubusercontent.com/u/3441017?v=4)](https://github.com/hisorange "hisorange (186 commits)")[![PoOwAa](https://avatars.githubusercontent.com/u/5154520?v=4)](https://github.com/PoOwAa "PoOwAa (61 commits)")[![pataar](https://avatars.githubusercontent.com/u/3403851?v=4)](https://github.com/pataar "pataar (36 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![matthewnessworthy](https://avatars.githubusercontent.com/u/5653887?v=4)](https://github.com/matthewnessworthy "matthewnessworthy (4 commits)")[![stokic](https://avatars.githubusercontent.com/u/2147162?v=4)](https://github.com/stokic "stokic (3 commits)")[![SudoGetBeer](https://avatars.githubusercontent.com/u/7324694?v=4)](https://github.com/SudoGetBeer "SudoGetBeer (3 commits)")[![rogervila](https://avatars.githubusercontent.com/u/6053012?v=4)](https://github.com/rogervila "rogervila (2 commits)")[![irazasyed](https://avatars.githubusercontent.com/u/1915268?v=4)](https://github.com/irazasyed "irazasyed (2 commits)")[![xutongle](https://avatars.githubusercontent.com/u/46956076?v=4)](https://github.com/xutongle "xutongle (2 commits)")[![antonioanerao](https://avatars.githubusercontent.com/u/21377886?v=4)](https://github.com/antonioanerao "antonioanerao (1 commits)")[![mylesduncanking](https://avatars.githubusercontent.com/u/19204499?v=4)](https://github.com/mylesduncanking "mylesduncanking (1 commits)")[![ovdsteen](https://avatars.githubusercontent.com/u/1948804?v=4)](https://github.com/ovdsteen "ovdsteen (1 commits)")[![potsky](https://avatars.githubusercontent.com/u/408237?v=4)](https://github.com/potsky "potsky (1 commits)")[![rhynodesigns](https://avatars.githubusercontent.com/u/2198266?v=4)](https://github.com/rhynodesigns "rhynodesigns (1 commits)")[![Shelob9](https://avatars.githubusercontent.com/u/1994311?v=4)](https://github.com/Shelob9 "Shelob9 (1 commits)")[![shiroamada](https://avatars.githubusercontent.com/u/2062946?v=4)](https://github.com/shiroamada "shiroamada (1 commits)")[![xiCO2k](https://avatars.githubusercontent.com/u/823088?v=4)](https://github.com/xiCO2k "xiCO2k (1 commits)")[![mrothauer](https://avatars.githubusercontent.com/u/527787?v=4)](https://github.com/mrothauer "mrothauer (1 commits)")[![apiaget](https://avatars.githubusercontent.com/u/634083?v=4)](https://github.com/apiaget "apiaget (1 commits)")

---

Tags

bot-detectionbrowserbrowser-detectioncrawler-detectionlaravelmobile-detectionua-parseruser-agent-parserbrowserlaravelmobileuser agentdetecttablethisorangeanalyse

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pataar-browser-detect/health.svg)

```
[![Health](https://phpackages.com/badges/pataar-browser-detect/health.svg)](https://phpackages.com/packages/pataar-browser-detect)
```

###  Alternatives

[hisorange/browser-detect

Browser &amp; Mobile detection package for Laravel.

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

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

4.8k70.8M494](/packages/jenssegers-agent)[karmendra/laravel-agent-detector

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

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

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

1515.4k1](/packages/al-saloul-agent)

PHPackages © 2026

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