Using Browscap

Ankush Sharma edited this page Apr 14, 2016 · 20 revisions

Browscap is provided in several different formats, the most commonly used is the INI format. The tool on GitHub at browscap/browscap itself can't be used directly on your site, this tool is ONLY used to generate the INI files to put on the official site at browscap.org. We also keep the issue tracker on here to make it easy for you to report missing/incorrect UA strings. In order to actually use the INI files, there are several options available to you, which are listed below.

PHP

Using browscap/browscap-php

This is an officially supported method of loading the files

This package is based on GaretJax/phpbrowscap, but is maintained by the official Browscap team. It is an officially supported method of loading the files (we do not support GaretJax's version, although we sometimes contribute changes back). This method of using Browscap allows you to both download and parse the file using one package.

Note: for Symfony 2 users, you can use the browscap/BrowscapBundle which is maintained by Joshua Estes.

Using get_browser()

PHP actually has a built-in method of parsing the browscap.ini file. However, for this method you must manually download the correct browscap.ini (any of the PHP versions) and configure PHP for the correct directory. This might not be possible in a shared host environment, so you might need to look at a userland implementation, e.g. the browscap/browscap-php package.

WordPress plugin WP SlimStat

The WordPress plugin WP SlimStat also uses browscap.ini, but it uses a customised version of the INI files which come bundled with the plugin. Visit getusedtoit/wp-slimstat for more info.

Crossjoin\Browscap

A complete rewrite of the browscap/browscap-php library was done by contributor @ziege and is claimed to be much more memory-friendly. https://github.com/crossjoin/Browscap.

Perl

The HTTP::Browscap perl module is available from http://search.cpan.org/~gwyn/HTTP-Browscap-0.06/Browscap.pm.

Python

User @robertlabrie from @tnwinc made a Python script that parses the browscap.csv format. https://github.com/tnwinc/TA-browscap_express

ASP

Using browscap.dll

You can use the browscap.dll (MSWC.BrowserType component) to parse the INI file in ASP. You would need to manaully download the browscap.ini files for this method.

C# / IIS

Udo Schmal's C# Class

http://www.gocher.me/C-Sharp-Browscap

Udo Schmal's ISAPI filter

http://www.gocher.me/Browscap-ISAPI-Filter

Pascal

Udo Schmal's Pascal Class

A contributor, Udo Schmal created a class for loading the files using Pascal. More info can be found at http://www.gocher.me/browscap (in German).

Udo Schmal's Apache Module

Gocher also created an Apache module written in Pascal that loads the browscap.ini files. More info can be found at http://www.gocher.me/browscap-apache-module (in German).

ColdFusion

https://github.com/henrylearn2rock/BrowscapCFC

Ruby

Ruby Gems exists for:

Splunk

Browscap can be used in Splunk - see here

Java