-
Notifications
You must be signed in to change notification settings - Fork 72
Using Browscap
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.
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. If you use this method, make sure you don't put the browscap.ini anywhere that PHP looks for and parses INI files, or you may see syntax errors.
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.
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.
The HTTP::Browscap perl module is available from http://search.cpan.org/~gwyn/HTTP-Browscap-0.06/Browscap.pm.
User @robertlabrie from @tnwinc made a Python script that parses the browscap.csv format. https://github.com/tnwinc/TA-browscap_express
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.
http://www.gocher.me/C-Sharp-Browscap
http://www.gocher.me/Browscap-ISAPI-Filter
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).
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).
https://github.com/henrylearn2rock/BrowscapCFC
Ruby Gems exists for:
Browscap can be used in Splunk - see here