PHPackages                             flamecore/user-agent - 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. flamecore/user-agent

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

flamecore/user-agent
====================

Simple browser detection for PHP

8106.3k↑183.1%1PHP

Since Jul 13Pushed 9y ago8 watchersCompare

[ Source](https://github.com/flamecore/user-agent)[ Packagist](https://packagist.org/packages/flamecore/user-agent)[ RSS](/packages/flamecore-user-agent/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

FlameCore UserAgent
===================

[](#flamecore-useragent)

[![Build Status](https://camo.githubusercontent.com/98896965ed352bb4a96398038b24191c3ab34f51715db02912bf096420a7c549/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f466c616d65436f72652f557365724167656e742e737667)](https://travis-ci.org/FlameCore/UserAgent)[![Scrutinizer](https://camo.githubusercontent.com/a9fe5ac47020c9e3e7d98da8536340b6f387c697a70be075cbf61e6bc868eed1/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f466c616d65436f72652f557365724167656e742e737667)](https://scrutinizer-ci.com/g/FlameCore/UserAgent)[![Coverage](https://camo.githubusercontent.com/8f94647da14760b0fff21d6c133cb2bdc6ca87c1cf5dad97cae213a21aa842de/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f466c616d65436f72652f557365724167656e742e737667)](https://scrutinizer-ci.com/g/FlameCore/UserAgent)[![License](https://camo.githubusercontent.com/557e41f56196f643fa99792692eb34d4a212f29963771abce48e8fa5c1f3ef53/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f666c616d65636f72652f757365722d6167656e742e737667)](http://www.flamecore.org/projects/user-agent)

This library provides simple browser detection for PHP. It uses a simple and fast algorithm to recognize major browsers.

The UserAgent package was developed for our spam-protection system [Gatekeeper](https://github.com/FlameCore/Gatekeeper).

Why you should use it
---------------------

[](#why-you-should-use-it)

PHP provides a native function to detect the user browser: [`get_browser()`](http://php.net/get_browser). This function requires the `browscap.ini` file which is 300KB+ in size. Loading and processing this file impacts the script performance. And sometimes, the production server just doesn't provide `browscap.ini`.

Although `get_browser()` surely provides excellent detection results, in most cases a much simpler method can be just as effective. The FlameCore UserAgent library has the advantage of being compact and easy to extend.

Usage
-----

[](#usage)

To make use of the API, include the vendor autoloader and use the classes:

```
namespace Acme\MyApplication;

use FlameCore\UserAgent\UserAgent;

require 'vendor/autoload.php';

// Create a user agent object
$userAgent = UserAgent::createFromGlobal();
```

Then the parsed values can be retrieved using the getter methods:

```
$userAgent->getBrowserName();      // firefox
$userAgent->getBrowserVersion();   // 3.6
$userAgent->getBrowserEngine();    // gecko
$userAgent->getOperatingSystem();  // linux
```

When you create a `UserAgent` object, the current user agent string is used. You can specify another user agent string:

```
// Use another User Agent string
$userAgent = UserAgent::create('msnbot/2.0b (+http://search.msn.com/msnbot.htm)');
$userAgent->getBrowserName(); // msnbot

// Use current User Agent string
$userAgent = UserAgent::create($_SERVER['HTTP_USER_AGENT']);
// ... which is equivalent to:
$userAgent = UserAgent::createFromGlobal();
```

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

[](#installation)

### Install via Composer

[](#install-via-composer)

Create a file called `composer.json` in your project directory and put the following into it:

```
{
    "require": {
        "flamecore/user-agent": "dev-master"
    }
}

```

[Install Composer](https://getcomposer.org/doc/00-intro.md#installation-nix) if you don't already have it present on your system:

```
$ curl -sS https://getcomposer.org/installer | php

```

Use Composer to [download the vendor libraries](https://getcomposer.org/doc/00-intro.md#using-composer) and generate the vendor/autoload.php file:

```
$ php composer.phar install

```

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

[](#requirements)

- You must have at least PHP version 5.4 installed on your system.

Contributors
------------

[](#contributors)

If you want to contribute, please see the [CONTRIBUTING](CONTRIBUTING.md) file first.

Thanks to the contributors:

- Christian Neff (secondtruth)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/82268b2432ab90f14c62445938bc3cd1340dc66e0463035df57891826b418016?d=identicon)[secondtruth](/maintainers/secondtruth)

---

Top Contributors

[![secondtruth](https://avatars.githubusercontent.com/u/416441?v=4)](https://github.com/secondtruth "secondtruth (20 commits)")[![naroga](https://avatars.githubusercontent.com/u/3511149?v=4)](https://github.com/naroga "naroga (4 commits)")

---

Tags

browser-detectionphp-libraryuser-agent

### Embed Badge

![Health badge](/badges/flamecore-user-agent/health.svg)

```
[![Health](https://phpackages.com/badges/flamecore-user-agent/health.svg)](https://phpackages.com/packages/flamecore-user-agent)
```

###  Alternatives

[reach-digital/magento2-betterindexers

254.2k](/packages/reach-digital-magento2-betterindexers)[davidrjenni/scip-php

SCIP Code Intelligence Protocol (SCIP) indexer for PHP

171.9k](/packages/davidrjenni-scip-php)

PHPackages © 2026

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