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

ActiveLibrary

hocvt/browser-detect
====================

Browser &amp; Mobile detection package for Laravel.

v5.0.4(2y ago)0857↓50%MITPHPPHP ^8.1

Since Jan 6Pushed 2y agoCompare

[ Source](https://github.com/vuthaihoc/browser-detect)[ Packagist](https://packagist.org/packages/hocvt/browser-detect)[ Docs](https://github.com/hisorange/browser-detect)[ RSS](/packages/hocvt-browser-detect/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (4)Used By (0)

[![Browser Detection Logo](https://user-images.githubusercontent.com/3441017/126362397-d9767164-4f44-4d41-a3cd-b669e10e95dc.png)](https://user-images.githubusercontent.com/3441017/126362397-d9767164-4f44-4d41-a3cd-b669e10e95dc.png)

Browser Detection v5.0 by *[hisorange](https://hisorange.me)*
-------------------------------------------------------------

[](#browser-detection-v50-by-hisorange)

[![Latest Stable Version](https://camo.githubusercontent.com/bfd4b6e41361e29694fb8bf751288ac7ba8add67f0dce57188a7b0de03db74a6/68747470733a2f2f706f7365722e707567782e6f72672f6869736f72616e67652f62726f777365722d6465746563742f762f737461626c65)](https://packagist.org/packages/hisorange/browser-detect)[![Build](https://github.com/hisorange/browser-detect/actions/workflows/latest.yml/badge.svg?branch=stable)](https://github.com/hisorange/browser-detect/actions/workflows/latest.yml)[![Coverage Status](https://camo.githubusercontent.com/f9fa9fd010089fe425a31ccb88f7e93a75f6ea9c6325e56e05fe73537de11186/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6869736f72616e67652f62726f777365722d6465746563742f62616467652e737667)](https://coveralls.io/github/hisorange/browser-detect)[![Total Downloads](https://camo.githubusercontent.com/5aec5d6091601de7026afc17bcccef77217a353ec238d2dd97b09fec2de9caf7/68747470733a2f2f706f7365722e707567782e6f72672f6869736f72616e67652f62726f777365722d6465746563742f646f776e6c6f616473)](https://packagist.org/packages/hisorange/browser-detect)[![License](https://camo.githubusercontent.com/24812cb6038f1e7a0841dc3626d52dec17381095b1f4c3e25b13529d0a966e04/68747470733a2f2f706f7365722e707567782e6f72672f6869736f72616e67652f62726f777365722d6465746563742f6c6963656e7365)](https://packagist.org/packages/hisorange/browser-detect)

Easy to use package to identify the visitor's browser details and device type. Magic is **not** involved the results are generated by multiple well tested and developed packages.

Supports **every Laravel** version between **4.0 » 10.x**; Also tested on **every PHP** version between **5.6 » 8.2**.

### How to install

[](#how-to-install)

---

```
composer require hisorange/browser-detect
```

Yep, it's ready to be used by You! ^.^

### How to use

[](#how-to-use)

---

In Your code just call the **Browser** facade:

```
use Browser;

// Determine the user's device type is simple as this:
$isMobile = Browser::isMobile();
Browser::isTablet();
Browser::isDesktop();

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

// Every wondered if it is a bot who loading Your page?
if (Browser::isBot()) {
    echo 'No need to wonder anymore!';
}

// Check for common vendors.
if (Browser::isFirefox() || Browser::isOpera()) {
    $response .= '';
}

// Sometimes You may want to serve different content based on the OS.
if (Browser::isAndroid()) {
    $response .= 'Install our Android App!';
} elseif (Browser::isMac() && Browser::isMobile()) {
    $response .= 'Install our iOS App!';
}
```

Even in Your blade templates:

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

{-- Every result key is supported --}
@browser('isBot')
    Bots are identified too :)
@endbrowser
```

Easy peasy, ain't it?

### Version support

[](#version-support)

---

The following matrix has been continuously tested by the great and awesome **GitHub Actions**!

-----Browser Detect 1.xBrowser Detect 2.xBrowser Detect 3.xBrowser Detect 4.xBrowser Detect 5.xLaravel 4.x✓✓---Laravel 5.x-✓✓--Laravel 6.x---✓-Laravel 7.x---✓-Laravel 8.x---4.4+-Laravel 9.x---4.4+✓Laravel 10.x----✓Standalone---4.2+✓Since 2013 the package runs tests on every possible PHP / Laravel version matrix.

### Standalone mode, without Laravel!

[](#standalone-mode-without-laravel)

---

Based on community requests; Now You can use the library without Laravel. Just simply use the Parser class as a static object.

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

if (Browser::isLinux()) {
    // Works as well!
}
```

### Available API calls

[](#available-api-calls)

---

Every call on the **Browser** facade is proxied to a result object, so the following information are available on Your result too, where You can use the \[array\] syntax to access them.

CallResponseInternal TypeBrowser::userAgent()Current visitor's HTTP\_USER\_AGENT string.*(string)*Browser::isMobile()Is this a mobile device.*(boolean)*Browser::isTablet()Is this a tablet device.*(boolean)*Browser::isDesktop()Is this a desktop computer.*(boolean)*Browser::isBot()Is this a crawler / bot.*(boolean)*Browser::deviceType()Enumerated response for \[Mobile, Tablet, Desktop, and Bot\]*(string)***Browser related functions**Browser::browserName()Browser's human friendly name like Firefox 3.6, Chrome 42.*(string)*Browser::browserFamily()Browser's vendor like Chrome, Firefox, Opera.*(string)*Browser::browserVersion()Browser's human friendly version string.*(string)*Browser::browserVersionMajor()Browser's [semantic](https://semver.org/) major version.*(integer)*Browser::browserVersionMinor()Browser's [semantic](https://semver.org/) minor version.*(integer)*Browser::browserVersionPatch()Browser's [semantic](https://semver.org/) patch version.*(integer)*Browser::browserEngine()Browser's engine like: Blink, WebKit, Gecko.*(string)***Operating system related functions**Browser::platformName()Operating system's human friendly name like Windows XP, Mac 10.*(string)*Browser::platformFamily()Operating system's vendor like Linux, Windows, Mac.*(string)*Browser::platformVersion()Operating system's human friendly version like XP, Vista, 10.*(integer)*Browser::platformVersionMajor()Operating system's [semantic](https://semver.org/) major version.*(integer)*Browser::platformVersionMinor()Operating system's [semantic](https://semver.org/) minor version.*(integer)*Browser::platformVersionPatch()Operating system's [semantic](https://semver.org/) patch version.*(integer)***Operating system extended functions**Browser::isWindows()Is this a windows operating system.*(boolean)*Browser::isLinux()Is this a linux based operating system.*(boolean)*Browser::isMac()Is this an iOS or Mac based operating system.*(boolean)*Browser::isAndroid()Is this an Android operating system.*(boolean)***Device related functions**Browser::deviceFamily()Device's vendor like Samsung, Apple, Huawei.*(string)*Browser::deviceModel()Device's brand name like iPad, iPhone, Nexus.*(string)***Browser vendor related functions**Browser::isChrome()Is this a chrome browser.*(boolean)*Browser::isFirefox()Is this a firefox browser.*(boolean)*Browser::isOpera()Is this an opera browser.*(boolean)*Browser::isSafari()Is this a safari browser.*(boolean)*Browser::isIE()Checks if the browser is an some kind of Internet Explorer (or Trident)*(boolean)*Browser::isIEVersion()Compares to a given IE version*(boolean)*Browser::isEdge()Is this a microsoft edge browser.*(boolean)***Miscellaneous**Browser::isInApp()Check for browsers rendered inside applications like android webview.*(boolean)*### Configuration, personalization

[](#configuration-personalization)

---

If You are using Laravel then after installation run the following command:

```
# Will copy a config file to ~/app/config/browser-detect.php
php artisan vendor:publish
```

For standalone mode to apply Your custom configuration:

```
use hisorange\BrowserDetect\Parser;

$browser = new Parser(null, null, [
    'cache' => [
        'interval' => 86400 // This will override the default configuration.
    ]
]);

$result = $browser->detect();
```

Since the package aims to be easy to use, there is not much to configure. But You can customize the cache and security values.

### Advanced Usage Information

[](#advanced-usage-information)

---

The code is designed to be an easy to use style, so every call You make on the **Browser** facade will access the result object and get the data for You, but You can parse agents other than the current user's.

```
// When You call the detect function You will get a result object, from the current user's agent.
$result = Browser::detect();

// If You wanna get browser details from a user agent other than the current user call the parse function.
$result = Browser::parse('Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14');
```

Worthy notion! The parser only parsing each user agent string once and then caches it, it uses an in-memory runtime cache for multiple calls in a single page load; And it will use the application's cache to persist the result for a week or so, this should provide You with a sufficient caching mechanism so the detection will cost less than **0.02 millisecond**, this was tested with an 80,000 fake visit.

### Changelog

[](#changelog)

---

See the detailed changes in the [CHANGELOG](CHANGELOG.md) file.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.6% 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 ~1 days

Total

2

Last Release

839d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2509658?v=4)[Stupid Dev](/maintainers/vuthaihoc)[@vuthaihoc](https://github.com/vuthaihoc)

---

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)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 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)")[![vuthaihoc](https://avatars.githubusercontent.com/u/2509658?v=4)](https://github.com/vuthaihoc "vuthaihoc (3 commits)")[![xutongle](https://avatars.githubusercontent.com/u/46956076?v=4)](https://github.com/xutongle "xutongle (2 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)")[![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)")[![emnsen](https://avatars.githubusercontent.com/u/5148536?v=4)](https://github.com/emnsen "emnsen (1 commits)")

---

Tags

browserlaravelmobileuser agentdetecttablethisorangeanalyse

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[hisorange/browser-detect

Browser &amp; Mobile detection package for Laravel.

1.1k10.1M50](/packages/hisorange-browser-detect)[jenssegers/agent

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

4.8k67.8M440](/packages/jenssegers-agent)[karmendra/laravel-agent-detector

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

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

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

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

PHPackages © 2026

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