PHPackages                             nodes/browscap - 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. nodes/browscap

AbandonedArchivedLibrary

nodes/browscap
==============

Fork of the officially supported Browscap PHP. Standalone replacement for php's native get\_browser() function

1.0.1(9y ago)07.2kMITPHPPHP ^5.6|^7.0

Since Apr 21Pushed 9y ago3 watchersCompare

[ Source](https://github.com/nodes-php/browscap)[ Packagist](https://packagist.org/packages/nodes/browscap)[ Docs](https://github.com/browscap/browscap-php)[ RSS](/packages/nodes-browscap/feed)WikiDiscussions master Synced 2mo ago

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

Browser Capabilities PHP Project
================================

[](#browser-capabilities-php-project)

This is a userland replacement for PHP's native `get_browser()` function, which is *officially supported* by the Browser Capabilities Project.

**Note that you are currently viewing the unstable master branch (will be 3.x versions). If you're installing via `composer require browscap/browscap-php`, depending on your minimum stability, you may be using the latest version 2.x, so please read the documentation for that branch [here](https://github.com/browscap/browscap-php/tree/2.x).**

[![Build Status](https://camo.githubusercontent.com/fa67de86e154fbb528443d4546a5a7f36db6695d1bf9f7335f43ca64c380d55f/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f62726f77736361702f62726f77736361702d7068702e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/browscap/browscap-php) [![Code Coverage](https://camo.githubusercontent.com/434792812608013311b0457d4605160b9732d53eec0dbfe4f1c8b71164717e51/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62726f77736361702f62726f77736361702d7068702f6261646765732f636f7665726167652e706e673f733d36316362333263613833643230353365643962313430363930623665313864666130306534363339)](https://scrutinizer-ci.com/g/browscap/browscap-php/) [![Scrutinizer Quality Score](https://camo.githubusercontent.com/a10997424eee3355d92d09933b4dd69ee9ae8b4ba41ac9c17bb15791d62c8f15/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62726f77736361702f62726f77736361702d7068702f6261646765732f7175616c6974792d73636f72652e706e673f733d64623163633136393962316362366163366165343637353465663936313232313765626135353236)](https://scrutinizer-ci.com/g/browscap/browscap-php/)

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

[](#installation)

Run the command below to install via Composer

```
composer require browscap/browscap-php
```

Then you may identify the current user agent like so:

```
use BrowscapPHP\Browscap;

$browscap = new Browscap();
$info = $browscap->getBrowser();
```

Recommended Setup
-----------------

[](#recommended-setup)

Before you can start, you have to download the browscap.ini file and convert it into a cache. There are two ways.

1. Download the file and convert it in two steps. The downloaded file will be stored in a local file, but there is no check if the remote file has changed. If your cache gets corrupted you only need to rerun the `convert` command.

```
vendor/bin/browscap-php browscap:fetch
vendor/bin/browscap-php browscap:convert
```

2. Download the file and convert it in one step. The downloaded file will not be stored in a local file, but there is a check if the remote file has changed. If your cache gets corrupted you have clean the cache and restart the process.

```
vendor/bin/browscap-php browscap:update
```

If you only want to check if a new version of the browscap.ini is available, you can use the `browscap:check-update` command.

Note: Both ways to create/update the cache and also checking the update will use the `standard` mode file as default. If you want more detailed information you may change this with the `remote-file` option. Please use the help function this parameter.

```
vendor/bin/browscap-php browscap:update --remote-file Full_PHP_BrowscapINI
```

Each operation expect fetch uses a cache inside the `resources` directory inside the project. If you update this library with composer, the cache is cleared also. If you want to avoid this and want to set your own cache folder, you can use the `cache` option. If you do this, you have to set a Cache Instance for this this path (see below).

```
vendor/bin/browscap-php browscap:update --cache ./browscap-cache
```

Note: Each operation (fetch, update, check-update) which fetches data from the remote host browscap.org may run into the rate limit of that site. If this happens an Exception is thrown.

A sample using composer with taking the useragent from the global $\_SERVER variable.

```
require 'vendor/autoload.php';

// The Browscap class is in the BrowscapPHP namespace, so import it
use BrowscapPHP\Browscap;

// Create a new Browscap object (loads or creates the cache)
$bc = new Browscap();

// Get information about the current browser's user agent
$current_browser = $bc->getBrowser();
```

If you have an user agent you can change the function

```
$current_browser = $bc->getBrowser($the_user_agent);
```

If you want to log something that happens with the detector you may set an logger. This logger has to implement the logger interface from Psr\\Log\\LoggerInterface

```
$bc = new Browscap();
$bc->setLogger($logger);
$current_browser = $bc->getBrowser();
```

If you want to use an other cache than the file cache, you may set a different one. You have to change the cache adapter before building the cache with the `convert` or the `update` commands.

NOTE: If you want to use a different cache, the samples above will not work, because they are using a predefined file cache

This cache adapter has to implement the adapter interface from WurflCache\\Adapter\\AdapterInterface

```
$adapter = new \WurflCache\Adapter\Memcache();
$bc = new Browscap();
$bc->setCache($adapter);
$current_browser = $bc->getBrowser();
```

In this sample a memcache is used to store the full version of the bropwscap.ini file

```
$adapter = new \WurflCache\Adapter\Memcache();

$bc = new Browscap();
$bc
    ->setCache($adapter)
    ->update(\BrowscapPHP\Helper\IniLoader::PHP_INI_FULL)
;
```

If you are behind a proxy you have to set a configuration with the proxy data. Parts who are not needed for your connection (like the port if the standard port is used) dont need to be set

```
$proxyConfig = array(
    'ProxyProtocol' => 'http',
    'ProxyHost'     => 'example.org',
    //'ProxyPort'     => null,
    'ProxyAuth'     => 'basic',
    'ProxyUser'     => 'your username',
    'ProxyPassword' => 'your super secret password',
);

$bc = new Browscap();
$bc->setOptions($proxyConfig);
```

Issues and feature requests
---------------------------

[](#issues-and-feature-requests)

Please report your issues and ask for new features on the GitHub Issue Tracker at

Please report incorrectly identified User Agents and browser detect in the browscap.ini file here:

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

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

###  Release Activity

Cadence

Every ~271 days

Total

2

Last Release

3404d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3aaee2c2b7632254faa8a589817712bdab2c7d46778fb26994eef75b20ec9c08?d=identicon)[nodes](/maintainers/nodes)

---

Top Contributors

[![mimmi20](https://avatars.githubusercontent.com/u/1120192?v=4)](https://github.com/mimmi20 "mimmi20 (388 commits)")[![asgrim](https://avatars.githubusercontent.com/u/496145?v=4)](https://github.com/asgrim "asgrim (117 commits)")[![GaretJax](https://avatars.githubusercontent.com/u/86236?v=4)](https://github.com/GaretJax "GaretJax (20 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (13 commits)")[![quentin389](https://avatars.githubusercontent.com/u/2136749?v=4)](https://github.com/quentin389 "quentin389 (9 commits)")[![DaAwesomeP](https://avatars.githubusercontent.com/u/4472083?v=4)](https://github.com/DaAwesomeP "DaAwesomeP (5 commits)")[![DominikTo](https://avatars.githubusercontent.com/u/1384635?v=4)](https://github.com/DominikTo "DominikTo (5 commits)")[![tmolitor-stud-tu](https://avatars.githubusercontent.com/u/6234248?v=4)](https://github.com/tmolitor-stud-tu "tmolitor-stud-tu (4 commits)")[![vitorbrandao](https://avatars.githubusercontent.com/u/109226?v=4)](https://github.com/vitorbrandao "vitorbrandao (4 commits)")[![JoshuaEstes](https://avatars.githubusercontent.com/u/447419?v=4)](https://github.com/JoshuaEstes "JoshuaEstes (3 commits)")[![cziegenberg](https://avatars.githubusercontent.com/u/1983424?v=4)](https://github.com/cziegenberg "cziegenberg (3 commits)")[![jonathaningram](https://avatars.githubusercontent.com/u/626664?v=4)](https://github.com/jonathaningram "jonathaningram (3 commits)")[![ThaDafinser](https://avatars.githubusercontent.com/u/533017?v=4)](https://github.com/ThaDafinser "ThaDafinser (3 commits)")[![frederikbosch](https://avatars.githubusercontent.com/u/1552577?v=4)](https://github.com/frederikbosch "frederikbosch (2 commits)")[![smatyas](https://avatars.githubusercontent.com/u/534550?v=4)](https://github.com/smatyas "smatyas (1 commits)")[![soullivaneuh](https://avatars.githubusercontent.com/u/1698357?v=4)](https://github.com/soullivaneuh "soullivaneuh (1 commits)")[![erunion](https://avatars.githubusercontent.com/u/33762?v=4)](https://github.com/erunion "erunion (1 commits)")[![Casperhr](https://avatars.githubusercontent.com/u/1279756?v=4)](https://github.com/Casperhr "Casperhr (1 commits)")[![BassemN](https://avatars.githubusercontent.com/u/3768012?v=4)](https://github.com/BassemN "BassemN (1 commits)")[![WanderingZombie](https://avatars.githubusercontent.com/u/675501?v=4)](https://github.com/WanderingZombie "WanderingZombie (1 commits)")

---

Tags

browseruser agentget\_browsercapabilities

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/nodes-browscap/health.svg)

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

###  Alternatives

[browscap/browscap-php

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

4413.8M22](/packages/browscap-browscap-php)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[garetjax/phpbrowscap

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

437862.4k5](/packages/garetjax-phpbrowscap)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)

PHPackages © 2026

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