ua-parser
is a multi-language port of BrowserScope's user agent string parser.
The crux of the original parser--the data collected by Steve Souders over the years--has been extracted into a separate YAML file so as to be reusable as is by implementations in other programming languages.
ua-parser
is just a small wrapper around this data.
- PHP: Dave Olsen (@dmolsen)
regexes.yaml
: Lindsey Simon & Tobie Langel
#ua-parser on freenode.
Please read the contributors' guide
There are a few other libraries which make use of ua-parser's patterns. These include:
require("uaparser.php");
$ua = "Mozilla/5.0 (Macintosh; Intel Ma...";
$parser = new UAParser;
$result = $parser->parse($ua);
print $result->ua->family; // Safari
print $result->ua->major; // 6
print $result->ua->minor; // 0
print $result->ua->patch; // 2
print $result->ua->toString; // Safari 6.0.2
print $result->ua->toVersionString; // 6.0.2
print $result->os->family; // Mac OS X
print $result->os->major; // 10
print $result->os->minor; // 7
print $result->os->patch; // 5
print $result->os->patch_minor; // [null]
print $result->os->toString; // Mac OS X 10.7.5
print $result->os->toVersionString; // 10.7.5
print $result->device->family; // Other
print $result->toFullString; // Safari 6.0.2/Mac OS X 10.7.5
print $result->uaOriginal; // Mozilla/5.0 (Macintosh; Intel Ma...
More information is available in the README in the PHP directory
The data contained in regexes.yaml
is Copyright 2009 Google Inc. and available under the Apache License, Version 2.0.
The PHP port is Copyright (c) 2011-2012 Dave Olsen and is available under the MIT license.