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

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

crlang/browser.php
==================

A PHP Class to detect a user's Browser. PHP类来检测用户的浏览器。

v2.0.0(5y ago)07MITPHPPHP &gt;=7.2

Since Jun 26Pushed 5y agoCompare

[ Source](https://github.com/crlang/Browser.php)[ Packagist](https://packagist.org/packages/crlang/browser.php)[ Docs](https://github.com/crlang/Browser.php)[ RSS](/packages/crlang-browserphp/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

crlang/browser.php
==================

[](#crlangbrowserphp)

[![Build Status](https://camo.githubusercontent.com/8eaa71c925cdfe41e95a8424e34c87d99b4f449cfcd682b564871cdb63ccaab0/68747470733a2f2f7472617669732d63692e6f72672f63726c616e672f42726f777365722e7068702e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/crlang/Browser.php)

Helps detect the user's browser and platform at the PHP level via the user agent

[中文简介](README_zh)

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

[](#installation)

You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):

```
composer require crlang/browser.php

```

If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:

```
composer require --dev crlang/browser.php

```

Typical Usage:
--------------

[](#typical-usage)

```
$browser = new Browser();
echo $browser->getBrowser();
```

Browser Detection
-----------------

[](#browser-detection)

This solution identifies the following Browsers and does a best-guess on the version:

- Opera (`Browser::BROWSER_OPERA`)
- WebTV (`Browser::BROWSER_WEBTV`)
- NetPositive (`Browser::BROWSER_NETPOSITIVE`)
- Edge (`Browser::BROWSER_EDGE`)
- Internet Explorer (`Browser::BROWSER_IE`)
- Pocket Internet Explorer (`Browser::BROWSER_POCKET_IE`)
- Galeon (`Browser::BROWSER_GALEON`)
- Konqueror (`Browser::BROWSER_KONQUEROR`)
- iCab (`Browser::BROWSER_ICAB`)
- OmniWeb (`Browser::BROWSER_OMNIWEB`)
- Phoenix (`Browser::BROWSER_PHOENIX`)
- Firebird (`Browser::BROWSER_FIREBIRD`)
- UCBrowser (`Browser::BROWSER_UCBROWSER`)
- Firefox (`Browser::BROWSER_FIREFOX`)
- Mozilla (`Browser::BROWSER_MOZILLA`)
- Palemoon (`Browser::BROWSER_PALEMOON`)
- curl (`Browser::BROWSER_CURL`)
- wget (`Browser::BROWSER_WGET`)
- Amaya (`Browser::BROWSER_AMAYA`)
- Lynx (`Browser::BROWSER_LYNX`)
- Safari (`Browser::BROWSER_SAFARI`)
- Playstation (`Browser::BROWSER_PLAYSTATION`)
- iPhone (`Browser::BROWSER_IPHONE`)
- iPod (`Browser::BROWSER_IPOD`)
- Google.s Android(`Browser::BROWSER_ANDROID`)
- Google.s Chrome(`Browser::BROWSER_CHROME`)
- GoogleBot(`Browser::BROWSER_GOOGLEBOT`)
- Yahoo!.s Slurp(`Browser::BROWSER_SLURP`)
- W3C.s Validator(`Browser::BROWSER_W3CVALIDATOR`)
- BlackBerry(`Browser::BROWSER_BLACKBERRY`)

Operating System Detection
--------------------------

[](#operating-system-detection)

This solution identifies the following Operating Systems:

- Windows (`Browser::PLATFORM_WINDOWS`)
- Windows CE (`Browser::PLATFORM_WINDOWS_CE`)
- Apple (`Browser::PLATFORM_APPLE`)
- Linux (`Browser::PLATFORM_LINUX`)
- Android (`Browser::PLATFORM_ANDROID`)
- OS/2 (`Browser::PLATFORM_OS2`)
- BeOS (`Browser::PLATFORM_BEOS`)
- iPhone (`Browser::PLATFORM_IPHONE`)
- iPod (`Browser::PLATFORM_IPOD`)
- BlackBerry (`Browser::PLATFORM_BLACKBERRY`)
- FreeBSD (`Browser::PLATFORM_FREEBSD`)
- OpenBSD (`Browser::PLATFORM_OPENBSD`)
- NetBSD (`Browser::PLATFORM_NETBSD`)
- SunOS (`Browser::PLATFORM_SUNOS`)
- OpenSolaris (`Browser::PLATFORM_OPENSOLARIS`)
- iPad (`Browser::PLATFORM_IPAD`)

Testing
-------

[](#testing)

The testing with PHPUnit against known user agents available in tests/lists. Each file is tab delimited with the following fields:

User Agent, User Agent Type, Browser, Version, Operating System, Operating System Version

eg

```
Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16	Browser	Opera	12.16	Linux	Linux
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1   Browser	Chrome	14.0.835.186	Macintosh	OS X		10_7_2

```

Tests can be run by phpunit:

```
vendor/phpunit/phpunit/phpunit
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70.9% 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 ~107 days

Recently: every ~157 days

Total

7

Last Release

1874d ago

Major Versions

v1.9.6 → v2.0.02021-03-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13017513?v=4)[crlang](/maintainers/crlang)[@crlang](https://github.com/crlang)

---

Top Contributors

[![cbschuld](https://avatars.githubusercontent.com/u/231867?v=4)](https://github.com/cbschuld "cbschuld (83 commits)")[![Marco129](https://avatars.githubusercontent.com/u/4252133?v=4)](https://github.com/Marco129 "Marco129 (8 commits)")[![bburnichon](https://avatars.githubusercontent.com/u/2437286?v=4)](https://github.com/bburnichon "bburnichon (3 commits)")[![Rigiytip](https://avatars.githubusercontent.com/u/2422544?v=4)](https://github.com/Rigiytip "Rigiytip (3 commits)")[![mavrick](https://avatars.githubusercontent.com/u/357659?v=4)](https://github.com/mavrick "mavrick (2 commits)")[![romainneutron](https://avatars.githubusercontent.com/u/137574?v=4)](https://github.com/romainneutron "romainneutron (2 commits)")[![stiko](https://avatars.githubusercontent.com/u/8698522?v=4)](https://github.com/stiko "stiko (2 commits)")[![adaxi](https://avatars.githubusercontent.com/u/474682?v=4)](https://github.com/adaxi "adaxi (2 commits)")[![GramThanos](https://avatars.githubusercontent.com/u/14858959?v=4)](https://github.com/GramThanos "GramThanos (2 commits)")[![Otamay](https://avatars.githubusercontent.com/u/905688?v=4)](https://github.com/Otamay "Otamay (2 commits)")[![trejjam](https://avatars.githubusercontent.com/u/3594540?v=4)](https://github.com/trejjam "trejjam (1 commits)")[![baasha](https://avatars.githubusercontent.com/u/636120?v=4)](https://github.com/baasha "baasha (1 commits)")[![crlang](https://avatars.githubusercontent.com/u/13017513?v=4)](https://github.com/crlang "crlang (1 commits)")[![davidus-sk](https://avatars.githubusercontent.com/u/10680124?v=4)](https://github.com/davidus-sk "davidus-sk (1 commits)")[![FootballFan141](https://avatars.githubusercontent.com/u/6156499?v=4)](https://github.com/FootballFan141 "FootballFan141 (1 commits)")[![igaponov](https://avatars.githubusercontent.com/u/4271889?v=4)](https://github.com/igaponov "igaponov (1 commits)")[![jasonlam604](https://avatars.githubusercontent.com/u/1707104?v=4)](https://github.com/jasonlam604 "jasonlam604 (1 commits)")[![misilot](https://avatars.githubusercontent.com/u/1446856?v=4)](https://github.com/misilot "misilot (1 commits)")

---

Tags

browseruser agentdetection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/crlang-browserphp/health.svg)

```
[![Health](https://phpackages.com/badges/crlang-browserphp/health.svg)](https://phpackages.com/packages/crlang-browserphp)
```

###  Alternatives

[jenssegers/agent

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

4.8k67.8M440](/packages/jenssegers-agent)[cbschuld/browser.php

A PHP Class to detect a user's Browser. This encapsulation provides a breakdown of the browser and the version of the browser using the browser's user-agent string. This is not a guaranteed solution but provides an overall accurate way to detect what browser a user is using.

5876.7M19](/packages/cbschuld-browserphp)[hisorange/browser-detect

Browser &amp; Mobile detection package for Laravel.

1.1k10.1M50](/packages/hisorange-browser-detect)[foroco/php-browser-detection

Ultra fast PHP library to detect browser, OS, platform and device type by User-Agent parsing

1554.7M7](/packages/foroco-php-browser-detection)[garetjax/phpbrowscap

Standalone replacement for php's native get\_browser() function

437862.4k5](/packages/garetjax-phpbrowscap)[wolfcast/browser-detection

The Wolfcast BrowserDetection PHP class facilitates the identification of the user's environment such as Web browser, version, platform family, platform version or if it's a mobile device or not.

1391.0M7](/packages/wolfcast-browser-detection)

PHPackages © 2026

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