PHPackages                             flycro/ua-parser-modern-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. flycro/ua-parser-modern-php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

flycro/ua-parser-modern-php
===========================

PHP port of ua-parser-modern - detect browser, engine, OS, CPU and device from User-Agent strings

v0.1.1(2d ago)01MITPHPPHP ^8.2CI passing

Since Mar 19Pushed 2d agoCompare

[ Source](https://github.com/Flycro/ua-parser-modern-php)[ Packagist](https://packagist.org/packages/flycro/ua-parser-modern-php)[ Docs](https://github.com/flycro/ua-parser-modern-php)[ RSS](/packages/flycro-ua-parser-modern-php/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

ua-parser-modern-php
====================

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

PHP port of [ua-parser-modern](https://github.com/antfu-collective/ua-parser-modern) - detect Browser, Engine, OS, CPU, and Device type/model from User-Agent strings.

All regex patterns are ported 1:1 from the original JavaScript source to ensure identical detection behavior.

Requirements
------------

[](#requirements)

- PHP 8.2+
- `ext-mbstring`

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

[](#installation)

```
composer require flycro/ua-parser-modern-php
```

Usage
-----

[](#usage)

### Parse everything at once

[](#parse-everything-at-once)

```
use UaParserModern\UserAgentParser;

$result = UserAgentParser::parse($userAgent);

$result->browser->name;    // 'Chrome'
$result->browser->version; // '120.0.0.0'
$result->browser->major;   // '120'

$result->os->name;         // 'Windows'
$result->os->version;      // '10'

$result->device->model;    // null
$result->device->type;     // null
$result->device->vendor;   // null

$result->engine->name;     // 'Blink'
$result->engine->version;  // '120.0.0.0'

$result->cpu->architecture; // 'amd64'
```

### Parse individual components

[](#parse-individual-components)

Only parse what you need:

```
$browser = UserAgentParser::parseBrowser($userAgent);
$browser->name;    // 'Chrome'
$browser->version; // '120.0.0.0'
$browser->major;   // '120'

$os = UserAgentParser::parseOS($userAgent);
$os->name;    // 'Windows'
$os->version; // '10'

$device = UserAgentParser::parseDevice($userAgent);
$engine = UserAgentParser::parseEngine($userAgent);
$cpu    = UserAgentParser::parseCPU($userAgent);
```

### JSON serialization

[](#json-serialization)

All result objects implement `JsonSerializable`:

```
$result = UserAgentParser::parse($userAgent);

json_encode($result);
// {"ua":"...","browser":{"name":"Chrome","version":"120.0.0.0","major":"120"},...}
```

### Convert to array

[](#convert-to-array)

```
$result->toArray();          // Full nested array
$result->browser->toArray(); // ['name' => 'Chrome', 'version' => '120.0.0.0', 'major' => '120']
```

Result Types
------------

[](#result-types)

All results are readonly value objects:

MethodReturn TypeProperties`parse()``ParseResult``ua`, `browser`, `device`, `engine`, `os`, `cpu``parseBrowser()``BrowserResult``name`, `version`, `major``parseDevice()``DeviceResult``model`, `type`, `vendor``parseEngine()``EngineResult``name`, `version``parseOS()``OSResult``name`, `version``parseCPU()``CPUResult``architecture`Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

This is a PHP port of [ua-parser-modern](https://github.com/antfu-collective/ua-parser-modern) by [Anthony Fu](https://github.com/antfu), which was forked from [my-ua-parser](https://github.com/mcollina/my-ua-parser) by [Matteo Collina](https://github.com/mcollina), which was a fork of [ua-parser-js](https://github.com/nicedoc/ua-parser-modern) by [Faisal Salman](https://github.com/nicedoc).

- [Anthony Fu](https://github.com/antfu)
- [Matteo Collina](https://github.com/mcollina)
- [Faisal Salman](https://github.com/nicedoc)
- [Flycro](https://github.com/flycro)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 84% of packages

Maintenance99

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/64dad6c4c3e3adb697c3b67a3150cb93eae1f98f3df1c6dd1196f64b2d82e897?d=identicon)[Flycro](/maintainers/Flycro)

---

Top Contributors

[![Flycro](https://avatars.githubusercontent.com/u/48244006?v=4)](https://github.com/Flycro "Flycro (3 commits)")

---

Tags

browserparserCPUuser agentdeviceos

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[thadafinser/user-agent-parser

UserAgent parsing done right http://useragent.mkf.solutions/

246316.9k2](/packages/thadafinser-user-agent-parser)[donatj/phpuseragentparser

Lightning fast, minimalist PHP UserAgent string parser.

59517.0M51](/packages/donatj-phpuseragentparser)[eprofos/user-agent-analyzer

A powerful Symfony bundle for user-agent analysis. It provides accurate detection of operating systems (Windows, MacOS, Linux, iOS, Android...), browsers (Chrome, Firefox, Safari...), and device types (Desktop, Mobile, Tablet, TV...). Supports specific version detection and includes advanced handling of special cases like WebViews and compatibility modes. Features comprehensive logging and detailed analysis results.

182.0k](/packages/eprofos-user-agent-analyzer)[mimmi20/browser-detector

Library to detect Browsers and Devices

48152.3k3](/packages/mimmi20-browser-detector)

PHPackages © 2026

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