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

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

jstewmc/get-browser
===================

Get browser information

v2.0.1(9y ago)133MITPHPPHP ^7.0

Since Jul 31Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jstewmc/get-browser)[ Packagist](https://packagist.org/packages/jstewmc/get-browser)[ RSS](/packages/jstewmc-get-browser/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

get-browser
===========

[](#get-browser)

Get a browser's information.

```
namespace Jstewmc\GetBrowser;

// define the user-agent
$userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) '
    . 'AppleWebKit/601.6.17 (KHTML, like Gecko) Version/9.1.1 '
    . 'Safari/601.6.17';

// instantiate the service
$service = new GetBrowser();

// get the browser
$browser = $service($userAgent);

// return the request's browser information
$browser->getName();      // returns "Safari"
$browser->getVersion();   // returns "9.1.1"
$browser->getPlatform();  // returns "Macintosh"
```

In the real world, you'd probably get the user-agent string from the HTTP request, and you'd probably define the service in your Dependency Injection (DI) container. But, you get the idea!

This library uses the lightweight [donatj/phpuseragentparser](https://github.com/donatj/PhpUserAgent) library. Unlike PHP's native [get\_browser()](http://php.net/manual/en/function.get-browser.php) function which requires a separate `browscap.ini` file, the Php User Agent library uses regex to determine a browser's *name*, *version*, and *platform*.

This library adds some simple validation and provides an object-oriented approach to accessing the browser's information.

License
-------

[](#license)

[MIT](https://github.com/jstewmc/get-browser/blob/master/LICENSE)

Author
------

[](#author)

[Jack Clayton](clayjs0@gmail.com)

Version
-------

[](#version)

### 2.0.1, December 10, 2016

[](#201-december-10-2016)

- Update README (fixes [\#1](https://github.com/jstewmc/get-browser/issues/1))

### 2.0.0, November, 24, 2016

[](#200-november-24-2016)

- Rename `Get` to `GetBrowser`.
- Refactor `GetBrowser`. I removed the dependency on the `Request` service. Instead, the browser's `User-Agent` header should be passed to the service's `__invoke()` method.
- Delete `Request`. It's no longer needed.
- Delete `Browser`. I moved the `Browser` object to a separate repository, [jstewmc/browser](https://github.com/jstewmc/browser).

### 1.0.0, August 16, 2016

[](#100-august-16-2016)

- Major release

### 0.1.0, July 31, 2016

[](#010-july-31-2016)

- Initial release

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~43 days

Total

4

Last Release

3489d ago

Major Versions

v0.1.0 → v1.0.02016-08-13

v1.0.0 → v2.0.02016-11-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/50fecae0a7fd2119681bc133e496e7166b01a59f850a3c909e100bd427c6b28b?d=identicon)[Jstewmc](/maintainers/Jstewmc)

---

Top Contributors

[![jstewmc](https://avatars.githubusercontent.com/u/1192893?v=4)](https://github.com/jstewmc "jstewmc (8 commits)")

---

Tags

phpbrowserjstewmc

### Embed Badge

![Health badge](/badges/jstewmc-get-browser/health.svg)

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

###  Alternatives

[hexydec/agentzero

A zero knowledge library for extracting information from User-Agent strings

40126.6k](/packages/hexydec-agentzero)[renoki-co/clusteer

Clusteer is a Puppeteer wrapper written for PHP, with the super-power of parallelizing pages across multiple browser instances.

891.2k](/packages/renoki-co-clusteer)[luka-dev/headless-task-server-php

Helper for sending requests to luka-dev/headless-task-server

109.8k](/packages/luka-dev-headless-task-server-php)

PHPackages © 2026

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