PHPackages                             whichbrowser/parser - 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. whichbrowser/parser

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

whichbrowser/parser
===================

Useragent sniffing library for PHP

v2.1.8(2y ago)1.8k11.6M—3.3%242[7 PRs](https://github.com/WhichBrowser/Parser-PHP/pulls)20MITPHPPHP &gt;=5.4.0

Since Nov 15Pushed 1y ago79 watchersCompare

[ Source](https://github.com/WhichBrowser/Parser-PHP)[ Packagist](https://packagist.org/packages/whichbrowser/parser)[ Docs](http://whichbrowser.net)[ RSS](/packages/whichbrowser-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (8)Versions (63)Used By (20)

[![](https://camo.githubusercontent.com/e408e57e783acd0c2f616f1a06328c40e9259dd934405e63a04ccb469337bbfe/68747470733a2f2f6170692e776869636862726f777365722e6e65742f776869636862726f777365722e737667)](https://camo.githubusercontent.com/e408e57e783acd0c2f616f1a06328c40e9259dd934405e63a04ccb469337bbfe/68747470733a2f2f6170692e776869636862726f777365722e6e65742f776869636862726f777365722e737667)

This is an extremely complicated and almost completely useless browser sniffing library. Useless because you shouldn't use browser sniffing. So stop right now and go read something about feature detecting instead. I'm serious. Go away. You'll thank me later.

WhichBrowser/Parser-PHP
=======================

[](#whichbrowserparser-php)

The PHP version of WhichBrowser for use on a server. Fully compatible with PHP 7.0 or higher, including PHP 8.

[![Build](https://github.com/WhichBrowser/Parser-PHP/workflows/Build/badge.svg)](https://github.com/WhichBrowser/Parser-PHP/workflows/Build/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/23ed35109d5d303618f8ba8352c234bacb32d654422e9e8b09c21799cdd5cf96/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f576869636842726f777365722f5061727365722d5048502f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/WhichBrowser/Parser-PHP?branch=master)[![License](https://camo.githubusercontent.com/d918b116e62afda9608fd57b233c4580b1248aedf6964a7c88ffcefd2046ce62/68747470733a2f2f706f7365722e707567782e6f72672f776869636862726f777365722f7061727365722f6c6963656e7365)](https://packagist.org/packages/whichbrowser/parser)[![Latest Stable Version](https://camo.githubusercontent.com/a6e691a75ff4f9e95518f128c3a52de8dcbad91bbedb40c082f3519b1e1a6985/68747470733a2f2f706f7365722e707567782e6f72672f776869636862726f777365722f7061727365722f762f737461626c65)](https://packagist.org/packages/whichbrowser/parser)

[![Twitter Follow](https://camo.githubusercontent.com/296d8494abd3f70bae4650cdbb37c1c1e5083653f620a40f9b3b459cc31c5c71/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f776869636862726f777365726c69622e7376673f7374796c653d736f6369616c)](https://twitter.com/whichbrowserlib)

Also available:

- [WhichBrowser/Parser-JavaScript](https://github.com/WhichBrowser/Parser-JavaScript)
    A JavaScript version of WhichBrowser for use with Node.js on the server
- [WhichBrowser/Server](https://github.com/WhichBrowser/Server)
    A server written in PHP that provides a JavaScript API for use in the browser

---

About WhichBrowser
------------------

[](#about-whichbrowser)

**But why *almost completely useless* and not completely useless?**Well, there is always an exception to the rule. There are valid reasons to do browser sniffing: to improve the user experience or to gather intelligence about which browsers are used on your website. My website is html5test.com and I wanted to know which score belongs to which browser. And to do that you need a browser sniffing library.

**Why is it extremely complicated?**
Because everybody lies. Seriously, there is not a single browser that is completely truthful. Almost all browsers say they are Netscape 5 and almost all WebKit browsers say they are based on Gecko. Even Internet Explorer 11 now no longer claims to be IE at all, but instead an unnamed browser that is like Gecko. And it gets worse. That is why it is complicated.

**What kind of information does it give?**You get a nice object which has information about the browser, rendering engine, os and device. It gives you names and versions and even device manufacturer and model. And WhichBrowser is pretty tenacious. It gives you info that others don't. For example:

```
JUC (Linux; U; 2.3.6; zh-cn; GT-I8150; 480*800) UCWEB8.7.4.225/145/800
UC Browser 8.7 on a Samsung Galaxy W running Android 2.3.6

```

Android is never mentioned

```
Mozilla/5.0 (Series40; Nokia501/10.0.2; Profile/MIDP-2.1 Configuration/CLDC-1.1) Gecko/20100401 S40OviBrowser/3.0.0.0.73
Nokia Xpress 3.0.0 on a Nokia Asha 501 running Nokia Asha Platform

```

Despite the useragent header claiming to be a Series40 device, we know it's actually running the Asha Platform and we also know that OviBrowser has been renamed to Nokia Xpress.

```
Opera/9.80 (X11; Linux zvav; U; zh) Presto/2.8.119 Version/11.10
Opera Mini on a Nokia 5230 running Series60 5.0

```

The useragent header looks like Opera 11.10 on Linux, but we know it's Opera Mini. We can even figure out the real operating system and device model from other headers.

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

[](#requirements)

WhichBrowser requires with PHP 7.0 or higher and supports PHP 8. WhichBrowser is compatible with the PSR-4 autoloading standard and follows PSR-1 and PSR-2 coding style.

How to install it
-----------------

[](#how-to-install-it)

You can install WhichBrowser by using Composer - the standard package manager for PHP. The package is called `whichbrowser/parser`.

```
composer require whichbrowser/parser

```

You can easily update WhichBrowser by running a simple command.

```
composer update whichbrowser/parser

```

You should run this command as often as possible. You might even want to consider setting up a cron job for this purpose.

How to use it
-------------

[](#how-to-use-it)

The first step require the Composer autoloader:

```
