Search by

jooservices / useragent

jooservices

Deterministic, dataset-backed synthetic User-Agent profiles for tests and fixtures.

Package info

github.com/jooservices/useragent

pkg:composer/jooservices/useragent

Statistics

Installs: 447

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v4.1.0 2026-11-29 22:06 UTC

README

CI OpenSSF Scorecard PHP Version GitHub Release License: MIT

PHP 8.5+ deterministic generator of coherent synthetic browser User-Agent profiles for tests, fixtures, and controlled client configuration.

Features

  • Checksummed bundled dataset with provenance on every result
  • Seeded, weighted, uniform, and round-robin profile selection
  • Immutable fluent request builder and bounded unique batch generation
  • generatePool() for a list of ready-to-use User-Agent strings
  • Stable profile identity for logs and fixtures
  • Non-interactive CLI with JSON and NDJSON output

Requirements

  • PHP >= 8.5
  • ext-json
  • jooservices/dto ^3.0 || ^4.0 (DTO v4 also requires ext-mbstring)

Installation

composer require jooservices/useragent:^4.1

Quick start

use JOOservices\UserAgent\Generator;

$generator = Generator::create();
$pool = $generator->builder()
    ->chrome()
    ->windows()
    ->desktop()
    ->seed(42)
    ->generatePool(10);

Using the pool with jooservices/client

jooservices/client does not depend on this package. Install it separately when you need HTTP requests; client ^4.6 supports DTO v3 and v4, as does this package. The packages have independent version numbers.

use JOOservices\Client\Client\ClientBuilder;
use JOOservices\UserAgent\Generator;

$pool = Generator::create()->builder()->seed(42)->generatePool(10);
$client = ClientBuilder::create()->withRotatingUserAgent($pool)->build();

The seed makes pool generation repeatable. The client picks a member of the pool independently for each request; that choice is not seeded by this package.

Command line

vendor/bin/useragent --help
vendor/bin/useragent --browser=chrome --os=windows --seed=42
vendor/bin/useragent --count=10 --format=ndjson --seed=42

The CLI writes User-Agent strings as text, or complete generation results as JSON or NDJSON. Invalid options exit with status 2; generation errors exit with status 1.

Design notes

  • Reuse one Generator instance in long-running processes; it loads and validates the bundled dataset once.
  • A User-Agent string is synthetic metadata, not browser emulation.
  • The package performs no network access and does not accept a caller-provided dataset path.

Documentation

Development

make build
make install
make lint
make test
make ci

Community

License

MIT — see LICENSE.