PHPackages                             vipnytt/useragentparser - 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. vipnytt/useragentparser

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

vipnytt/useragentparser
=======================

User-Agent parser for robot rule sets

v1.0.7(1y ago)2966.0k↓57%13MITPHPPHP ^7.2 || ^8.0CI failing

Since Apr 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/VIPnytt/UserAgentParser)[ Packagist](https://packagist.org/packages/vipnytt/useragentparser)[ Docs](https://github.com/VIPnytt/UserAgentParser)[ RSS](/packages/vipnytt-useragentparser/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (1)Versions (12)Used By (3)

[![Build Status](https://camo.githubusercontent.com/260fc42a87dbb0422afaa48a3a3023b7cb0009d5d1d9d93b3cb93493a6701076/68747470733a2f2f7472617669732d63692e6f72672f5649506e7974742f557365724167656e745061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/VIPnytt/UserAgentParser)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c102af3183679f38e0372d8b0ca20ef5b8dce2b7bf19d9038cbde2c51f35d9b4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5649506e7974742f557365724167656e745061727365722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/VIPnytt/UserAgentParser/?branch=master)[![Maintainability](https://camo.githubusercontent.com/f5fd242015d0408fe72fdc2d30f74cc9531b22a34570e8ac8457b9afe7d7b9c9/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f33313963343734656233613638316335306261332f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/VIPnytt/UserAgentParser/maintainability)[![Test Coverage](https://camo.githubusercontent.com/155c4900b11f91a7af9e644a6e1bb1b04bf0e3e705afb5754526be60ee6f09f7/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f33313963343734656233613638316335306261332f746573745f636f766572616765)](https://codeclimate.com/github/VIPnytt/UserAgentParser/test_coverage)[![License](https://camo.githubusercontent.com/04ab6e9b0948177bcf106f99b78a1b0a9b64a8f056f05334ac89171a185eff22/68747470733a2f2f706f7365722e707567782e6f72672f5649506e7974742f557365724167656e745061727365722f6c6963656e7365)](https://github.com/VIPnytt/UserAgentParser/blob/master/LICENSE)[![Packagist](https://camo.githubusercontent.com/b9788d4ca21634937195ecbd5081038ab63055eb7d3246040dffc67ab30c2fea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7669706e7974742f757365726167656e747061727365722e737667)](https://packagist.org/packages/vipnytt/useragentparser)

User-Agent parser for robot rule sets
=====================================

[](#user-agent-parser-for-robot-rule-sets)

Parser and group determiner optimized for `robots.txt`, `X-Robots-tag` and `Robots-meta-tag` usage cases.

[![SensioLabsInsight](https://camo.githubusercontent.com/7e7ddf81a974780d7113ff522a71122ae1f305ad475c92a2dcff99ac3a262bc2/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31333836633134632d353436632d346334322d616335352d3931656133613361316165312f6269672e706e67)](https://insight.sensiolabs.com/projects/1386c14c-546c-4c42-ac55-91ea3a3a1ae1)

#### Requirements:

[](#requirements)

- PHP 5.5+, 7.0+ or 8.0+

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

[](#installation)

The library is available for install via [Composer](https://getcomposer.org). Just add this to your `composer.json` file:

```
{
    "require": {
        "vipnytt/useragentparser": "^1.0"
    }
}
```

Then run `php composer update`.

Features
--------

[](#features)

- Stripping of the version tag.
- List any *rule groups* the User-Agent belongs to.
- Determine the correct group of records by finding the group with the most specific User-agent that still matches.

### When to use it?

[](#when-to-use-it)

- When parsing `robots.txt` rule sets, for robots online.
- When parsing the `X-Robots-Tag` HTTP header.
- When parsing `Robots meta tags` in HTML / XHTML documents.

Note: *Full User-agent strings, like them sent by eg. web-browsers, is not compatible, this is by design.*Supported User-agent string formats are `UserAgentName/version` with or without the version tag. Eg. `MyWebCrawler/2.0` or just `MyWebCrawler`.

Getting Started
---------------

[](#getting-started)

### Strip the version tag.

[](#strip-the-version-tag)

```
use vipnytt\UserAgentParser;

$parser = new UserAgentParser('googlebot/2.1');
$product = $parser->getProduct()); // googlebot
```

### List different groups the User-agent belongs to

[](#list-different-groups-the-user-agent-belongs-to)

```
use vipnytt\UserAgentParser;

$parser = new UserAgentParser('googlebot-news/2.1');
$userAgents = $parser->getUserAgents());

array(
    'googlebot-news/2.1',
    'googlebot-news/2',
    'googlebot-news',
    'googlebotnews',
    'googlebot'
);
```

### Determine the correct group

[](#determine-the-correct-group)

Determine the correct group of records by finding the group with the most specific User-agent that still matches your rule sets.

```
use vipnytt\UserAgentParser;

$parser = new UserAgentParser('googlebot-news');
$match = $parser->getMostSpecific(['googlebot/2.1', 'googlebot-images', 'googlebot'])); // googlebot
```

### Cheat sheet

[](#cheat-sheet)

```
$parser = new UserAgentParser('MyCustomCrawler/1.2');

// Determine the correct rule set (robots.txt / robots meta tag / x-robots-tag)
$parser->getMostSpecific($array); // string

// Parse
$parser->getUserAgent(); // string 'MyCustomCrawler/1.2'
$parser->getProduct(); // string 'MyCustomCrawler'
$parser->getVersion(); // string '1.2'

// Crunch the data into groups, from most to less specific
$parser->getUserAgents(); // array
$parser->getProducts(); // array
$parser->getVersions(); // array
```

Specifications
--------------

[](#specifications)

- [Google Robots.txt specifications](https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt)
- [Google Robots meta tag and X-Robots-Tag HTTP header specifications](https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag)
- [Yandex robots.txt specifications](https://yandex.com/support/webmaster/controlling-robot/robots-txt.xml)
- [RFC 7231](https://tools.ietf.org/html/rfc7231), [2616](https://tools.ietf.org/html/rfc2616)
- [RFC 7230](https://tools.ietf.org/html/rfc7230), [2616](https://tools.ietf.org/html/rfc2616)

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance42

Moderate activity, may be stable

Popularity41

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 96.1% 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 ~324 days

Recently: every ~779 days

Total

11

Last Release

473d ago

Major Versions

v0.2.1 → v1.0.02016-07-15

PHP version history (5 changes)v0.1.0PHP &gt;=5.4.0

v0.2.1PHP &gt;=5.6.0

v1.0.1PHP &gt;=5.5.0

v1.0.4PHP ^5.5 || ^7.0

v1.0.5PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/26994e517317bb178af65b50893ef46ad3a1e6a54fe1fdd8056aece47620a703?d=identicon)[JanPetterMG](/maintainers/JanPetterMG)

---

Top Contributors

[![JanPetterMG](https://avatars.githubusercontent.com/u/11933090?v=4)](https://github.com/JanPetterMG "JanPetterMG (49 commits)")[![kudmni](https://avatars.githubusercontent.com/u/6409099?v=4)](https://github.com/kudmni "kudmni (2 commits)")

---

Tags

crawlerreprobotrobots-exclusion-protocolrobots-meta-tagrobots-tagrobots-txtspideruser-agentuser-agent-parserx-robots-tagcrawleruseragentuser agentspiderrobots.txtrobotx-robots-tagRobots meta tagRobots Exclusion ProtocolREP

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vipnytt-useragentparser/health.svg)

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

###  Alternatives

[jenssegers/agent

Desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

4.8k70.8M493](/packages/jenssegers-agent)[jaybizzle/laravel-crawler-detect

A Laravel package to detect web crawlers via the user agent

3222.7M18](/packages/jaybizzle-laravel-crawler-detect)[vdb/php-spider

A configurable and extensible PHP web spider

1.3k184.2k7](/packages/vdb-php-spider)[vipnytt/robotstxtparser

Robots.txt parsing library, with full support for every directive and specification.

26772.0k7](/packages/vipnytt-robotstxtparser)[foroco/php-browser-detection

Ultra fast PHP library to detect browser, OS, platform and device type by User-Agent parsing

1515.3M7](/packages/foroco-php-browser-detection)[woothee/woothee

Cross-language UserAgent classifier library, PHP implementation

107643.0k4](/packages/woothee-woothee)

PHPackages © 2026

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