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

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

invoke/browser
==============

A small class to detect the browser and the operating system

1.0.0(9y ago)131MITPHPPHP &gt;=5.6.0

Since Nov 18Pushed 9y ago7 watchersCompare

[ Source](https://github.com/invokemedia/browser)[ Packagist](https://packagist.org/packages/invoke/browser)[ RSS](/packages/invoke-browser/feed)WikiDiscussions master Synced 2mo ago

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

Browser
=======

[](#browser)

A very simple class that takes in a user agent string and returns the browser name (Firefox, Chrome, Opera, etc.) and also the Operating System (Mac, Windows, Android, etc.).

### Reasons

[](#reasons)

Firstly, you *should not* use browser sniffing for fearture detection, [use Modernizr](https://modernizr.com/).

We mainly use this for style tweaks between different browsers. Or sometimes you may need to add a little script (differences in keystroke handling can be difficult to feature detect) or tweak on a specific platform combination and so you might do a check to see if that makes sense.

The results are pretty crude. We only return `internet-explorer` if any verison of IE is found. There is *no version information*.

For the platform, we only return that operation system. This means all iOS devices (iPad, iPhone, iPod) would only return `ios`.

If you need to know specifics about the device, [use media queries](http://stephen.io/mediaqueries/).

### Support

[](#support)

**Platforms**

- Linux
- iOS
- Mac
- Windows
- Android
- Blackberry

**Browsers**

- MSIE
- UC Browser
- Trident
- Vivaldi
- Firefox
- Chrome
- Opera
- Opera Mini
- Safari

### Usage

[](#usage)

#### Methods

[](#methods)

```
getBrowser() // returns the string for the browser
getPlatform() // returns the platform for the browser
isMobile() // returns true for android and ios platforms (except iPad)
isDesktop() // returns the opposite of isMobile()

```

#### Properties

[](#properties)

```
