PHPackages                             ua-parser/uap-php - 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. ua-parser/uap-php

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

ua-parser/uap-php
=================

A multi-language port of Browserscope's user agent parser.

v3.10.0(10mo ago)55836.5M↓31.2%85[3 issues](https://github.com/ua-parser/uap-php/issues)[3 PRs](https://github.com/ua-parser/uap-php/pulls)20MITPHPPHP ^7.2 || ^8.0CI failing

Since Jan 11Pushed 10mo ago27 watchersCompare

[ Source](https://github.com/ua-parser/uap-php)[ Packagist](https://packagist.org/packages/ua-parser/uap-php)[ RSS](/packages/ua-parser-uap-php/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (8)Versions (38)Used By (20)Security (1)

ua-parser PHP Library
=====================

[](#ua-parser-php-library)

[![Gitter](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/ua-parser/uap-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://github.com/ua-parser/uap-php/actions/workflows/ci.yml/badge.svg)](https://github.com/ua-parser/uap-php/actions/workflows/ci.yml) [![Average time to resolve an issue](https://camo.githubusercontent.com/f095abe31ed3d6e2b56942466f99a461b8db76495b50f6f59f9a36c4556e34de/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f7265736f6c7574696f6e2f75612d7061727365722f7561702d7068702e737667)](http://isitmaintained.com/project/ua-parser/uap-php "Average time to resolve an issue") [![Percentage of issues still open](https://camo.githubusercontent.com/a2fb35971f594f7a17d6ff688e91fc33e6c21142a84d244113d92845d36adcb2/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f6f70656e2f75612d7061727365722f7561702d7068702e737667)](http://isitmaintained.com/project/ua-parser/uap-php "Percentage of issues still open")[![Latest Stable Version](https://camo.githubusercontent.com/5a3aa8948c0dbea959387ac4331dedfac0105178aa2fef4d867ec8e24cfd0c4e/68747470733a2f2f706f7365722e707567782e6f72672f75612d7061727365722f7561702d7068702f762f737461626c65)](https://packagist.org/packages/ua-parser/uap-php)[![Total Downloads](https://camo.githubusercontent.com/811dc4c7da3744c5070fc19e365fa68714f0a0ccb0128f76b2a36e83ed68e3bb/68747470733a2f2f706f7365722e707567782e6f72672f75612d7061727365722f7561702d7068702f646f776e6c6f616473)](https://packagist.org/packages/ua-parser/uap-php)[![License](https://camo.githubusercontent.com/4ea8d6ce73038fd2258cc0e6fcfc3ca4508136c9036be75dac08972f087e2c6f/68747470733a2f2f706f7365722e707567782e6f72672f75612d7061727365722f7561702d7068702f6c6963656e7365)](https://packagist.org/packages/ua-parser/uap-php)

This is the PHP library for the [uap-core](https://github.com/ua-parser/uap-core) project.

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

[](#installation)

```
composer require ua-parser/uap-php

```

Usage
-----

[](#usage)

Straightforward:

```
require_once 'vendor/autoload.php';
use UAParser\Parser;

$ua = "Mozilla/5.0 (Macintosh; Intel Ma...";

$parser = Parser::create();
$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->toVersion();       // 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->patchMinor;        // [null]
print $result->os->toString();        // Mac OS X 10.7.5
print $result->os->toVersion();       // 10.7.5

print $result->device->family;        // Other

print $result->toString();            // Safari 6.0.2/Mac OS X 10.7.5
print $result->originalUserAgent;     // Mozilla/5.0 (Macintosh; Intel Ma...
```

Using Your Own Custom regexes.php File
--------------------------------------

[](#using-your-own-custom-regexesphp-file)

You can use your own `regexes.php` file if you've customized the official file. I *strongly* encourage you to push back any changes you may have so others can benefit. That said, to use your own do the following:

```
require_once 'vendor/autoload.php';
use UAParser\Parser;

$parser = Parser::create("path/to/custom/regexes.php");
```

Using ua-parser PHP Library from the Command Line
-------------------------------------------------

[](#using-ua-parser-php-library-from-the-command-line)

A command line utility is now included with the PHP library. The following commands are supported:

### Get Usage Info

[](#get-usage-info)

Provides simple usage information:

```
php bin/uaparser

```

### Update the regexes.php File

[](#update-the-regexesphp-file)

Fetches an updated YAML file for `ua-parser` and overwrites the current regexes.php file. You can use the following as part of a cron job that runs nightly.

```
php bin/uaparser ua-parser:update [--no-backup]

```

By default creates a backup file. Use `--no-backup` to turn that feature off.

### Convert an Existing regexes.yaml File to regexes.php

[](#convert-an-existing-regexesyaml-file-to-regexesphp)

With the change to v2.0 you may have an existing and customized YAML file for `ua-parser`. Use the following to convert it to JSON.

```
php bin/uaparser ua-parser:convert [file]

```

### Grab Just the Latest regexes.yaml File From the Repository

[](#grab-just-the-latest-regexesyaml-file-from-the-repository)

If you need to add a new UA it's easier to edit the original YAML and then convert it to JSON.

```
php bin/uaparser ua-parser:fetch [file]

```

Fetches an updated YAML file. *Warning:* This method overwrites any existing `regexes.yaml` file.

### Parse a Single User Agent String

[](#parse-a-single-user-agent-string)

Parses a user agent string and dumps the results as a list.

```
php bin/uaparser ua-parser:parse "your user agent string"

```

### Parse a Webserver Log File

[](#parse-a-webserver-log-file)

Parses the supplied log file or log directory to test ua-parser. Saves the UA to a file when the UA or OS family aren't recognized or when the UA is listed as a generic smartphone or as a generic feature phone.

```
php bin/uaparser ua-parser:logfile [-f /path/to/logfile] [-d /path/to/logdir] [--include "*.gz"] [--exclude "*.gz"] errors.log

```

Multiple `--include` and `--exclude` parameters are allowed.

Credits
-------

[](#credits)

Thanks to the [original ua-parser team](http://code.google.com/p/ua-parser/people/list) for making the YAML file available for others to build upon.

Also, many thanks to the following major contributors to the PHP library:

- Bryan Shelton
- Michael Bond
- @rjd22
- Timo Tijhof
- Marcus Bointon
- Ryan Parman
- Pravin Dahal

Licensing
---------

[](#licensing)

- The library is licensed under the MIT license
- The user agents data from the ua-parser project is licensed under the Apache license
- The initial list of generic feature phones &amp; smartphones came from Mobile Web OSP under the MIT license
- The initial list of spiders was taken from Yiibu's profile project under the MIT license.

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance53

Moderate activity, may be stable

Popularity72

Solid adoption and visibility

Community47

Growing community involvement

Maturity80

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~106 days

Recently: every ~452 days

Total

37

Last Release

327d ago

PHP version history (3 changes)v3.4.7PHP &gt;=5.3.0

v3.9.8PHP ^7.2

v3.9.14PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/79707?v=4)[Lars Strojny](/maintainers/lstrojny)[@lstrojny](https://github.com/lstrojny)

---

Top Contributors

[![lstrojny](https://avatars.githubusercontent.com/u/79707?v=4)](https://github.com/lstrojny "lstrojny (146 commits)")[![dmolsen](https://avatars.githubusercontent.com/u/2746?v=4)](https://github.com/dmolsen "dmolsen (143 commits)")[![oligriffiths](https://avatars.githubusercontent.com/u/1246671?v=4)](https://github.com/oligriffiths "oligriffiths (9 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (8 commits)")[![LeoColomb](https://avatars.githubusercontent.com/u/846943?v=4)](https://github.com/LeoColomb "LeoColomb (7 commits)")[![Krinkle](https://avatars.githubusercontent.com/u/156867?v=4)](https://github.com/Krinkle "Krinkle (5 commits)")[![Synchro](https://avatars.githubusercontent.com/u/81561?v=4)](https://github.com/Synchro "Synchro (3 commits)")[![mondrake](https://avatars.githubusercontent.com/u/1174864?v=4)](https://github.com/mondrake "mondrake (3 commits)")[![secondtruth](https://avatars.githubusercontent.com/u/416441?v=4)](https://github.com/secondtruth "secondtruth (2 commits)")[![commenthol](https://avatars.githubusercontent.com/u/2604482?v=4)](https://github.com/commenthol "commenthol (2 commits)")[![tobie](https://avatars.githubusercontent.com/u/3392?v=4)](https://github.com/tobie "tobie (2 commits)")[![Ironholds](https://avatars.githubusercontent.com/u/2487262?v=4)](https://github.com/Ironholds "Ironholds (2 commits)")[![tomasvts](https://avatars.githubusercontent.com/u/4351937?v=4)](https://github.com/tomasvts "tomasvts (1 commits)")[![antonioribeiro](https://avatars.githubusercontent.com/u/3182864?v=4)](https://github.com/antonioribeiro "antonioribeiro (1 commits)")[![YoannChabert](https://avatars.githubusercontent.com/u/9531092?v=4)](https://github.com/YoannChabert "YoannChabert (1 commits)")[![ausi](https://avatars.githubusercontent.com/u/367169?v=4)](https://github.com/ausi "ausi (1 commits)")[![binaryoverload](https://avatars.githubusercontent.com/u/15330699?v=4)](https://github.com/binaryoverload "binaryoverload (1 commits)")[![carver](https://avatars.githubusercontent.com/u/205327?v=4)](https://github.com/carver "carver (1 commits)")[![dsazup](https://avatars.githubusercontent.com/u/8631224?v=4)](https://github.com/dsazup "dsazup (1 commits)")[![emteknetnz](https://avatars.githubusercontent.com/u/4809037?v=4)](https://github.com/emteknetnz "emteknetnz (1 commits)")

---

Tags

browserphpuser-agents

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ua-parser-uap-php/health.svg)

```
[![Health](https://phpackages.com/badges/ua-parser-uap-php/health.svg)](https://phpackages.com/packages/ua-parser-uap-php)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k193.1M3.0k](/packages/composer-composer)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[embed/embed

PHP library to retrieve page info using oembed, opengraph, etc

2.1k11.6M112](/packages/embed-embed)[azuracast/azuracast

The AzuraCast self-hosted web radio station management suite.

3.9k27.8k](/packages/azuracast-azuracast)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9017.2k55](/packages/open-dxp-opendxp)

PHPackages © 2026

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