{"id":27854768,"url":"https://github.com/hexydec/agentzero","last_synced_at":"2025-06-30T11:36:24.299Z","repository":{"id":182678274,"uuid":"668700785","full_name":"hexydec/agentzero","owner":"hexydec","description":"A fast and efficient string matching library for extracting information from User-Agent strings","archived":false,"fork":false,"pushed_at":"2025-05-03T20:29:47.000Z","size":673,"stargazers_count":29,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-04T09:11:52.160Z","etag":null,"topics":["php","user-agent","user-agent-parser","useragent","useragentparser"],"latest_commit_sha":null,"homepage":"https://hexydec.com/apps/user-agent-parser/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexydec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"docs/support.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-20T12:00:53.000Z","updated_at":"2025-05-03T20:10:57.000Z","dependencies_parsed_at":"2023-12-22T12:58:02.489Z","dependency_job_id":"c9142336-afc6-4e67-a4d7-88f63ca61599","html_url":"https://github.com/hexydec/agentzero","commit_stats":null,"previous_names":["hexydec/agentzero"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexydec%2Fagentzero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexydec%2Fagentzero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexydec%2Fagentzero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexydec%2Fagentzero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexydec","download_url":"https://codeload.github.com/hexydec/agentzero/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252310990,"owners_count":21727520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","user-agent","user-agent-parser","useragent","useragentparser"],"created_at":"2025-05-04T09:11:58.545Z","updated_at":"2025-06-30T11:36:24.290Z","avatar_url":"https://github.com/hexydec.png","language":"PHP","readme":"# AgentZero: Fast User-Agent Detection\nA library for extracting information from User-Agent strings very fast.\n\n![Licence: MIT](https://img.shields.io/badge/Licence-MIT-lightgrey.svg)\n[![Tests Status](https://github.com/hexydec/agentzero/actions/workflows/tests.yml/badge.svg)](https://github.com/hexydec/agentzero/actions/workflows/tests.yml)\n[![Code Coverage](https://scrutinizer-ci.com/g/hexydec/agentzero/badges/coverage.png?b=main)](https://scrutinizer-ci.com/g/hexydec/agentzero/code-structure/main/code-coverage)\n\n## Description\n\nDoesn't match full UA strings or patterns, instead it extracts and categorises features from UA strings, so is faster, and can handle new UA strings or variations of common UA patterns.\n\nMost User-Agent detection libraries rely on lists of regular expressions to match user agent string patterns and extract information. With lots of patterns you can do an ok job of getting this info, but it is not dynamic enough, which leads to minor variations or new UA strings not being captured, and they tend to be quite slow.\n\nAgentZero is a simple string matching library that splits the user agent strings up into tokens to extract information from each part, leading to more complete information, more flexibility in capturing new user agent strings, and better performance.\n\nYou can try out AgentZero online at [https://hexydec.com/apps/user-agent-parser/](https://hexydec.com/apps/user-agent-parser/), or run the supplied `index.php` file after installation.\n\n## Usage\n\nTo use AgentZero:\n\n```php\n$ua = $_SERVER['HTTP_USER_AGENT']; // or whatever UA you want e.g:\n$ua = 'Mozilla/5.0 (Linux; Android 13; Pixel 7 Pro Build/TD1A.220804.031; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 Instagram 301.1.0.33.110 Android (33/13; 420dpi; 1080x2116; Google/google; Pixel 7 Pro; cheetah; cheetah; en_GB; 517986703)';\n$browser = \\hexydec\\agentzero\\agentzero::parse($ua);\n```\nThe returned value will be something like:\n\n```php\n\\hexydec\\agentzero\\agentzero (\n\n\tpublic readonly string 'string' =\u003e string 'Mozilla/5.0 (Linux; Android 13; Pixel 7 Pro Build/TD1A.220804.031; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 Instagram 301.1.0.33.110 Android (33/13; 420dpi; 1080x2116; Google/google; Pixel 7 Pro; cheetah; cheetah; en_GB; 517986703)';\n\n\t// categories\n\tpublic readonly ?string 'type' =\u003e string 'human';\n\tpublic readonly ?string 'category' =\u003e string 'mobile';\n\n\t// device\n\tpublic readonly ?string 'vendor' =\u003e string 'Google';\n\tpublic readonly ?string 'device' =\u003e string 'Pixel';\n\tpublic readonly ?string 'model' =\u003e string '7 Pro';\n\tpublic readonly ?string 'build' =\u003e string 'TD1A.220804.031';\n\tpublic readonly ?int 'ram' =\u003e null;\n\n\t// architecture\n\tpublic readonly ?string 'processor' =\u003e null;\n\tpublic readonly ?string 'architecture' =\u003e null;\n\tpublic readonly ?int 'bits' =\u003e null;\n\tpublic readonly ?string 'cpu' =\u003e null;\n\tpublic readonly ?int 'cpuclock' =\u003e null;\n\n\t// platform\n\tpublic readonly ?string 'kernel' =\u003e string 'Linux';\n\tpublic readonly ?string 'platform' =\u003e string 'Android';\n\tpublic readonly ?string 'platformversion' =\u003e string '13';\n\n\t// browser\n\tpublic readonly ?string 'engine' =\u003e string 'Blink';\n\tpublic readonly ?string 'engineversion' =\u003e string '116.0.0.0';\n\tpublic readonly ?string 'browser' =\u003e string 'Chrome';\n\tpublic readonly ?string 'browserversion' =\u003e string '116.0.0.0';\n\tpublic readonly ?string 'browserstatus' =\u003e 'previous';\n\tpublic readonly ?string 'browserreleased' =\u003e '2023-09-15';\n\tpublic readonly ?string 'browserlatest' =\u003e '133.0.6943.54';\n\tpublic readonly ?string 'language' =\u003e string 'en-GB';\n\n\t// app\n\tpublic readonly ?string 'app' =\u003e string 'Instagram';\n\tpublic readonly ?string 'appname' =\u003e string 'Instagram';\n\tpublic readonly ?string 'appversion' =\u003e string '301.1.0.33.110';\n\tpublic readonly ?string 'framework' =\u003e null;\n\tpublic readonly ?string 'frameworkversion' =\u003e null;\n\tpublic readonly ?string 'url' =\u003e null;\n\n\t// network\n\tpublic readonly ?string 'nettype' =\u003e null;\n\tpublic readonly ?string 'proxy' =\u003e null;\n\n\t// screen\n\tpublic readonly ?int 'width' =\u003e int 1080;\n\tpublic readonly ?int 'height' =\u003e int 2116;\n\tpublic readonly ?int 'dpi' =\u003e int 420;\n\tpublic readonly ?float 'density' =\u003e null;\n\tpublic readonly ?bool 'darkmode' =\u003e null;;\n);\n```\n\nYou can read the [full list of properties here](docs/api.md).\n\n### Client Hints\n\nAgentZero now supports processing client hints for improved user-agent information. You must request the client hints to improve the information delivered through the user-agent string:\n\n```php\n\n// request client hints\n\\header('Accept-CH: Width, ECT, Device-Memory, Sec-CH-UA-Platform-Version, Sec-CH-UA-Model, Sec-CH-UA-Full-Version-List');\n\n// retrieve client hints\n$hints = \\hexydec\\agentzero\\agentzero::getHints();\n\n// parse\n$az = \\hexydec\\agentzero\\agentzero::parse($_SERVER['HTTP_USER_AGENT'], $hints);\n```\n\nNote that by using the `Accept-CH` header, you may receive client hints on subsequent requests, if you need the client hints on first call, use the `Critical-CH` header instead (Warning: This will cause an extra round trip as the browser must re-request the first page).\n\n### Browser Versions\n\nYou can determine the date the browser was released, latest version, and status, by setting where the version file should be cached:\n\n```php\n$config = [\n\t'versionscache' =\u003e __DIR__.'/cache/versions.json'\n];\n$az = \\hexydec\\agentzero\\agentzero::parse($_SERVER['HTTP_USER_AGENT'], [], $config);\nvar_dump(\n\t$ua-\u003ebrowserstatus, // either \"canary\", \"beta\", \"latest\", \"previous\", \"outdated\" (release over 2 years ago), \"legacy\" (released over 5 years ago)\n\t$ua-\u003ebrowserreleased, // the date the browser was released\n\t$us-\u003ebrowserlatest // the latest version number of the browser\n);\n\n```\n\nThe browser version information is sourced from [my browser versions project](https://github.com/hexydec/versions).\n\n## Supported Features\n\nAgentZero supports a wide range of architectures, browsers, rendering engines, platforms, devices, languages, and crawlers. [Access the full list on the Supported Features page](docs/support.md).\n\n## Installation\n\nThe easiest way to get up and running is to use composer:\n\n```\n$ composer require hexydec/agentzero\n```\n\n## Test Suite\n\nYou can run the test suite like this:\n\n### Linux\n```\n$ vendor/bin/phpunit\n```\n### Windows\n```\n\u003e vendor\\bin\\phpunit\n```\n\n## Support\n\nAgentZero supports PHP version 8.1+.\n\n## Contributing\n\nIf you find an issue with AgentZero, please create an issue in the tracker.\n\nIf you wish to fix an issue yourself, please fork the code, fix the issue, then create a pull request, and I will evaluate your submission.\n\n## Licence\n\nThe MIT License (MIT). Please see [License File](LICENCE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexydec%2Fagentzero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexydec%2Fagentzero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexydec%2Fagentzero/lists"}