# browser-detect: user agent and device detection for Laravel

> hisorange/browser-detect is a PHP package that answers what browser, operating system and device type a visitor is using, through a Browser facade in PHP and matching Blade directives, with a standalone parser for use outside Laravel. It suits a Laravel application that needs to branch on device type, and it stands on the user agent string rather than on feature detection.

**hisorange/browser-detect** — Browser Detection for Laravel by hisorange!

- Repository: https://github.com/hisorange/browser-detect
- Stars: 1,143 · Forks: 142
- Language: PHP
- License: MIT
- Published: 2026-10-19 · Updated: 2026-10-19 · Language: en
- Canonical page: https://hysenlabs.com/projects/hisorange-browser-detect

## A facade with a boolean for everything

browser-detect is an easy to use package to identify the visitor's browser details and device type, and the API is a single facade with a boolean method per fact. The install is one Composer command:

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

In your code you call the Browser facade, and the device question is three lines:

```php
use Browser;

$isMobile = Browser::isMobile();
Browser::isTablet();
Browser::isDesktop();
```

The same facade answers whether the visitor is a bot, whether the browser is Firefox or Opera, and which operating system they are on, so a branch that needs to push an Android app install link or an iOS one reads as a plain conditional. The package description makes a point about the results, saying that magic is not involved and that the results are generated by multiple well tested and developed packages, which is a fair way to describe a user agent parser that delegates to established libraries rather than rolling its own regexes.

## Blade directives for the same answers

The same information is available in Blade templates through directives, which is where the package earns its keep in a Laravel application. You get `@mobile`, `@tablet` and `@desktop` blocks, each with a matching end directive, and a generic `@browser` directive that takes any result key:

```blade
@mobile
    <p>This is the MOBILE template!</p>
    @include('your-mobile-template')
@endmobile

@tablet
    <p>This is the TABLET template!</p>
    <link rel="stylesheet" href="tablet.css" title="Reduce the page size, load what the user need">
@endtablet

@desktop
    <p>This is the DESKTOP template!</p>
@enddesktop

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

The generic directive is the interesting one, because it takes any result key rather than a fixed set, so the directive set does not have to grow with the API. The tablet example in the README also shows the intended use, serving a smaller stylesheet to a tablet to reduce the page size, which is the kind of decision that is easy to make and awkward to undo.

## The version matrix, and why it is the first thing to check

The README states that the package supports every Laravel version between 4.0 and 13.x and has been tested on every PHP version between 5.6 and 8.5, with the matrix continuously tested by GitHub Actions. The table is more precise than that headline. The 1.x line covers Laravel 4.x, the 2.x line covers Laravel 4.x and 5.x, the 3.x line covers Laravel 5.x, and the 4.x line covers Laravel 6.x and 7.x, with Laravel 8.x needing 4.4 or newer. The 5.x line is the current one and covers Laravel 9.x, 10.x, 11.x, 12.x and 13.x, and the standalone mode works from 4.2+ in the 4.x line and in 5.x. Since 2013 the package has run tests on every possible PHP and Laravel version matrix, which is the sort of maintenance record that matters for a package whose job is to keep working as the framework underneath it moves. The default branch is `stable`, and the releases are 5.1.0 on 2026-10-08, 5.0.3 on 2024-02-05 and 5.0.2 on 2024-01-06.

## Standalone mode, without the framework

The library does not require Laravel, and that was added on the back of community requests. Instead of the facade you use the Parser class as a static object:

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

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

That is the whole change, one use statement and the same method names. The consequence is that the package can be used in a Symfony application, a WordPress plugin, a Laravel Zero application, or a plain PHP script, and the same detection logic follows. For a Laravel application the facade is more ergonomic because it is registered with the container, but the underlying implementation is shared, so the standalone route is not a second-tier experience. It is worth knowing that this exists before you look for a separate package when you outgrow Laravel.

## The result object, and the array syntax

Every call on the Browser facade is proxied to a result object, and the same information is available on that result, where the array syntax is used to access it. The table of API calls is the reference. Browser::userAgent() gives the current visitor's HTTP_USER_AGENT string as a string. Browser::isMobile(), isTablet(), isDesktop() and isBot() give booleans, and deviceType() gives an enumerated response for Mobile, Tablet, Desktop and Bot. The browser calls give browserName() as a human friendly name like Firefox 3.6 or Chrome 42, browserFamily() as the vendor like Chrome, Firefox or Opera, browserVersion() as the human friendly version string, and browserVersionMajor(), browserVersionMinor() and browserVersionPatch() as the semantic major, minor and patch integers, plus browserEngine() returning the engine like Blink, WebKit or Gecko. The operating system functions follow the same pattern, and the reason to know about the array syntax is that the result object lets you pull a value you did not anticipate a method for.

## What this kind of detection cannot tell you

The limitation is the one inherent to the technique, and it is worth stating plainly because the package is very good at what it does. Everything here is derived from the user agent string, which is a claim the client makes about itself, and clients lie, spoof it and get it wrong. A crawler can present a desktop Chrome user agent, a browser can present a string from a decade ago, and a real user on an unusual device can be classified as a desktop. So isBot() is a heuristic against known crawler patterns rather than a guarantee, and a fork of Chromium with a modified user agent will defeat any user agent based scheme. The other limitation is scope. The package tells you which browser and which OS, not which features are present, so if you need to know whether the visitor's browser supports a particular API, that is a different question with a different tool, and the right tool is the feature itself. The package is at its best when you are serving different content, layouts or store links rather than when you are making security decisions.

## Conclusion

Adopt browser-detect if you are on Laravel and need device, OS and browser branching through a facade and Blade directives without wiring a user agent parser yourself. Skip it if you need to detect a specific browser feature rather than a browser identity, since a user agent string is a claim rather than a capability, and prefer feature detection where you can. Before you install, check the version matrix, because the 5.x line covers Laravel 9 to 13 and the standalone mode needs 4.2 or newer in the 4.x line, and note that the package is on the `stable` branch with a 5.1.0 release dated 2026-10-08.

## FAQ

### How do I install browser-detect?

Run `composer require hisorange/browser-detect`. The package supports every Laravel version between 4.0 and 13.x and has been tested on every PHP version between 5.6 and 8.5.

### Can browser-detect be used outside Laravel?

Yes. Use the Parser class as a static object instead of the facade, for example `use hisorange\BrowserDetect\Parser as Browser;`, and the same calls such as Browser::isLinux() work. The standalone mode has been supported since 4.2.

### Which Blade directives does browser-detect provide?

There are @mobile, @tablet and @desktop blocks with matching end directives, plus a generic @browser directive that takes any result key, for example @browser('isBot'), so any key from the result object can be used in a template.

### Which Laravel versions does browser-detect 5.x support?

Laravel 9.x, 10.x, 11.x, 12.x and 13.x, plus standalone use. The 4.x line covers Laravel 6.x and 7.x, and Laravel 8.x needs 4.4 or newer, while the 3.x line covers Laravel 5.x.

### What information can browser-detect return about the browser?

The user agent string, the browser name such as Firefox 3.6 or Chrome 42, the browser family like Chrome, Firefox or Opera, the full version string and its semantic major, minor and patch integers, the engine such as Blink, WebKit or Gecko, plus device type, bot detection and operating system calls.

## Sources

- [hisorange/browser-detect on GitHub](https://github.com/hisorange/browser-detect)
- [Issues](https://github.com/hisorange/browser-detect/issues)
- [License: MIT](https://github.com/hisorange/browser-detect/blob/stable/LICENSE)
- [README](https://github.com/hisorange/browser-detect/blob/stable/README.md)
- [Releases](https://github.com/hisorange/browser-detect/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/hisorange-browser-detect
