timeonegroup/udger-php

PHP agent string parser based on Udger https://udger.com/products/local_parser

5.0.1 2022-12-27 11:17 UTC

This package is auto-updated.

Last update: 2024-09-27 15:08:00 UTC


README

Fork from original lib : Udger

Local parser is very fast and accurate useragent string detection solution. Enables developers to locally install and integrate a highly-scalable product. We provide the detection of the devices (personal computer, tablet, Smart TV, Game console etc.), operating system, client SW type (browser, e-mail client etc.) and devices market name (example: Sony Xperia Tablet S, Nokia Lumia 820 etc.). It also provides information about IP addresses (Public proxies, VPN services, Tor exit nodes, Fake crawlers, Web scrapers, Datacenter name .. etc.)

  • Tested with more the 50.000 unique user agents.
  • Up to date data provided by https://udger.com/

Requirements

  • php >= 7.2.0
  • PDO

For local DB

For DB MySQL

  • PDO MySQL

Features

  • Fast
  • LRU cache
  • Released under the MIT
  • From local file or MySQL server

Install

composer require timeonegroup/udger-php

Usage

You should review the included examples (parse.php, account.php)

Examples

With MySQL
use Udger\ParserFactory;

require_once dirname(__DIR__) . '/vendor/autoload.php';

// creates a new UdgerParser object
$parser = ParserFactory::buildParserFromMySQL('mysql:host=db;dbname=udger;charset=UTF8', 'udger', 'udger');
$parser->setUA('Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0');
$parser->setIP("66.249.64.73");

$ret = $parser->parse();
With Data file
use Udger\ParserFactory;

require_once dirname(__DIR__) . '/vendor/autoload.php';

// creates a new UdgerParser object
$parser = ParserFactory::buildParserFromDataFile(sys_get_temp_dir() . '/udgercache/udgerdb_v3.dat');
$parser->setUA('Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0');
$parser->setIP("66.249.64.73");

$ret = $parser->parse();

Develop

Initialize

docker compose up db -d
docker compose run --rm init

Running tests

docker compose run --rm php ./vendor/bin/codecept run

Automatic updates download

Documentation for programmers

Author

TimeOne Group