{"id":13518864,"url":"https://github.com/donatj/PhpUserAgent","last_synced_at":"2025-03-31T11:30:44.034Z","repository":{"id":430674,"uuid":"1539133","full_name":"donatj/PhpUserAgent","owner":"donatj","description":"Lightning Fast, Minimalist PHP User Agent String Parser.","archived":false,"fork":false,"pushed_at":"2024-08-29T15:49:12.000Z","size":478,"stargazers_count":563,"open_issues_count":7,"forks_count":128,"subscribers_count":34,"default_branch":"master","last_synced_at":"2024-10-29T15:22:11.106Z","etag":null,"topics":["browser","composer","php","ua-parser","user-agent-parser"],"latest_commit_sha":null,"homepage":"https://donatstudios.com/PHP-Parser-HTTP_USER_AGENT","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/donatj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-03-28T23:25:33.000Z","updated_at":"2024-10-15T13:53:28.000Z","dependencies_parsed_at":"2024-11-15T21:37:31.519Z","dependency_job_id":"86fcf897-d422-4ec6-881a-51aeff8fa044","html_url":"https://github.com/donatj/PhpUserAgent","commit_stats":{"total_commits":373,"total_committers":20,"mean_commits":18.65,"dds":"0.10991957104557637","last_synced_commit":"e807895c848f0e4a0f0001bbb1c99cfb7181111e"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donatj%2FPhpUserAgent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donatj%2FPhpUserAgent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donatj%2FPhpUserAgent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donatj%2FPhpUserAgent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/donatj","download_url":"https://codeload.github.com/donatj/PhpUserAgent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246461474,"owners_count":20781332,"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":["browser","composer","php","ua-parser","user-agent-parser"],"created_at":"2024-08-01T05:01:50.119Z","updated_at":"2025-03-31T11:30:44.028Z","avatar_url":"https://github.com/donatj.png","language":"PHP","funding_links":[],"categories":["PHP","Tools and Related Libraries"],"sub_categories":["Detection"],"readme":"# PHP User Agent Parser\n\n[![Join the chat at https://gitter.im/PhpUserAgentParser/Lobby](https://badges.gitter.im/PhpUserAgentParser/Lobby.svg)](https://gitter.im/PhpUserAgentParser/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n\n[![Latest Stable Version](https://poser.pugx.org/donatj/phpuseragentparser/version)](https://packagist.org/packages/donatj/phpuseragentparser)\n[![Total Downloads](https://poser.pugx.org/donatj/phpuseragentparser/downloads)](https://packagist.org/packages/donatj/phpuseragentparser)\n[![License](https://poser.pugx.org/donatj/phpuseragentparser/license)](https://packagist.org/packages/donatj/phpuseragentparser)\n[![ci.yml](https://github.com/donatj/phpUserAgent/actions/workflows/ci.yml/badge.svg)](https://github.com/donatj/phpUserAgent/actions/workflows/ci.yml)\n\n\n## What It Is\n\nA simple, streamlined PHP user-agent parser!\n\nLicensed under the MIT license: https://www.opensource.org/licenses/mit-license.php\n\n## Upgrading to `1.*`\n\nThe new `1.*` release **does not break compatibility** with `0.*` and nothing need to change to upgrade. However, the global `parse_user_agent` is now deprecated; it has been replaced with the namespaced `\\donatj\\UserAgent\\parse_user_agent` and functions exactly the same. You can easily replace any existing call to `parse_user_agent` with `\\donatj\\UserAgent\\parse_user_agent`\n\nIn addition, 1.x adds a convenience object wrapper you may use should you prefer. More information on this is in the Usage section below.\n\n## Why Use This\n\nYou have your choice in user-agent parsers. This one detects **all modern browsers** in a very light, quick, understandable fashion.\nIt is less than 200 lines of code, and consists of just three regular expressions!\nIt can also correctly identify exotic versions of IE others fail on.\n\nIt offers 100% unit test coverage, is installable via Composer, and is very easy to use.\n\n## What It Does Not Do\n\nThis is not meant as a browser \"knowledge engine\" but rather a simple parser. Anything not adequately provided directly by the user agent string itself will simply not be provided by this.\n\n\n### OS Versions\n\nUser-agent strings **are not** a reliable source of OS Version!\n\n- Many agents simply don't send the information.\n- Others provide varying levels of accuracy.\n- Parsing Windows versions alone almost nearly doubles the size of the code.\n\nI'm much more interested in keeping this thing *tiny* and accurate than adding niché features and would rather focus on things that can be **done well**.\n\nAll that said, there is the start of a [branch to do it](https://github.com/donatj/PhpUserAgent/tree/os_version_detection) I created for a client if you want to poke it, I update it from time to time, but frankly if you need to *reliably detect OS Version*, using user-agent isn't the way to do it. I'd go with JavaScript.\n\n### Undetectable Browsers\n\n- **Brave** - Brave is simply not differentiable from Chrome. This was a design decision on their part.\n\n### Undetectable Platforms\n\n- **iPadOS 13+** - Starting with iPadOS 13 and further hardened in 14, iPadOS returns the **exact** same string as macOS. It is no longer distinguishable by UA string. (See: [#69](https://github.com/donatj/PhpUserAgent/issues/69))\n\n## Requirements\n\n- **php**: \u003e=5.4.0\n- **ext-ctype**: *\n\n## Installing\n\nPHP User Agent is available through Packagist via Composer.\n\nInstall the latest version with:\n\n```bash\ncomposer require 'donatj/phpuseragentparser'\n```\n\n## Usage\n\nThe classic procedural use is as simple as:\n\n```php\n\u003c?php\n\n// if you're using composer\nrequire __DIR__ . '/../vendor/autoload.php';\n\n// v0 style global function - @deprecated\n$uaInfo = parse_user_agent();\n// or\n// modern namespaced function\n$uaInfo = donatj\\UserAgent\\parse_user_agent();\n\necho $uaInfo[donatj\\UserAgent\\PLATFORM] . PHP_EOL;\necho $uaInfo[donatj\\UserAgent\\BROWSER] . PHP_EOL;\necho $uaInfo[donatj\\UserAgent\\BROWSER_VERSION] . PHP_EOL;\n\n```\n\nThe new object-oriented wrapper form:\n\n```php\n\u003c?php\n\nuse donatj\\UserAgent\\UserAgentParser;\n\n// if you're using composer\nrequire __DIR__ . '/../vendor/autoload.php';\n\n$parser = new UserAgentParser();\n\n// object-oriented call\n$ua = $parser-\u003eparse();\n// or\n// command style invocation\n$ua = $parser();\n\necho $ua-\u003eplatform() . PHP_EOL;\necho $ua-\u003ebrowser() . PHP_EOL;\necho $ua-\u003ebrowserVersion() . PHP_EOL;\n\n```\n\n## Currently Detected Platforms\n\nPredefined helper constants from `donatj\\UserAgent\\Platforms`  \n  \n| Constant | Platform |  \n|----------|----------|  \n| `Platforms::MACINTOSH` |  Macintosh |  \n| `Platforms::CHROME_OS` |  Chrome OS |  \n| `Platforms::LINUX` |  Linux |  \n| `Platforms::WINDOWS` |  Windows |  \n| `Platforms::ANDROID` |  Android |  \n| `Platforms::BLACKBERRY` |  BlackBerry |  \n| `Platforms::FREEBSD` |  FreeBSD |  \n| `Platforms::FUCHSIA` |  Fuchsia |  \n| `Platforms::IPAD` |  iPad |  \n| `Platforms::IPHONE` |  iPhone |  \n| `Platforms::IPOD` |  iPod |  \n| `Platforms::KINDLE` |  Kindle |  \n| `Platforms::KINDLE_FIRE` |  Kindle Fire |  \n| `Platforms::NETBSD` |  NetBSD |  \n| `Platforms::NEW_NINTENDO_3DS` |  New Nintendo 3DS |  \n| `Platforms::NINTENDO_3DS` |  Nintendo 3DS |  \n| `Platforms::NINTENDO_DS` |  Nintendo DS |  \n| `Platforms::NINTENDO_SWITCH` |  Nintendo Switch |  \n| `Platforms::NINTENDO_WII` |  Nintendo Wii |  \n| `Platforms::NINTENDO_WIIU` |  Nintendo WiiU |  \n| `Platforms::OPENBSD` |  OpenBSD |  \n| `Platforms::PLAYBOOK` |  PlayBook |  \n| `Platforms::PLAYSTATION_3` |  PlayStation 3 |  \n| `Platforms::PLAYSTATION_4` |  PlayStation 4 |  \n| `Platforms::PLAYSTATION_5` |  PlayStation 5 |  \n| `Platforms::PLAYSTATION_VITA` |  PlayStation Vita |  \n| `Platforms::SAILFISH` |  Sailfish |  \n| `Platforms::SYMBIAN` |  Symbian |  \n| `Platforms::TIZEN` |  Tizen |  \n| `Platforms::WINDOWS_PHONE` |  Windows Phone |  \n| `Platforms::XBOX` |  Xbox |  \n| `Platforms::XBOX_ONE` |  Xbox One |\n\n## Currently Detected Browsers\n\nPredefined helper constants from `donatj\\UserAgent\\Browsers`  \n  \n| Constant | Browser |  \n|----------|----------|  \n| `Browsers::ADSBOT_GOOGLE` |  AdsBot-Google |  \n| `Browsers::ANDROID_BROWSER` |  Android Browser |  \n| `Browsers::APPLEBOT` |  Applebot |  \n| `Browsers::BAIDUSPIDER` |  Baiduspider |  \n| `Browsers::BINGBOT` |  bingbot |  \n| `Browsers::BLACKBERRY_BROWSER` |  BlackBerry Browser |  \n| `Browsers::BROWSER` |  Browser |  \n| `Browsers::BUNJALLOO` |  Bunjalloo |  \n| `Browsers::CAMINO` |  Camino |  \n| `Browsers::CHATGPT_USER` |  ChatGPT-User |  \n| `Browsers::CHROME` |  Chrome |  \n| `Browsers::CURL` |  curl |  \n| `Browsers::EDGE` |  Edge |  \n| `Browsers::FACEBOOKEXTERNALHIT` |  facebookexternalhit |  \n| `Browsers::FEEDVALIDATOR` |  FeedValidator |  \n| `Browsers::FIREFOX` |  Firefox |  \n| `Browsers::GOOGLEBOT` |  Googlebot |  \n| `Browsers::GOOGLEBOT_IMAGE` |  Googlebot-Image |  \n| `Browsers::GOOGLEBOT_VIDEO` |  Googlebot-Video |  \n| `Browsers::GPTBOT` |  GPTBot |  \n| `Browsers::HEADLESSCHROME` |  HeadlessChrome |  \n| `Browsers::IEMOBILE` |  IEMobile |  \n| `Browsers::IMESSAGEBOT` |  iMessageBot |  \n| `Browsers::KINDLE` |  Kindle |  \n| `Browsers::LYNX` |  Lynx |  \n| `Browsers::MASTODON` |  Mastodon |  \n| `Browsers::MIDORI` |  Midori |  \n| `Browsers::MIUIBROWSER` |  MiuiBrowser |  \n| `Browsers::MSIE` |  MSIE |  \n| `Browsers::MSNBOT_MEDIA` |  msnbot-media |  \n| `Browsers::NETFRONT` |  NetFront |  \n| `Browsers::NINTENDOBROWSER` |  NintendoBrowser |  \n| `Browsers::OAI_SEARCHBOT` |  OAI-SearchBot |  \n| `Browsers::OCULUSBROWSER` |  OculusBrowser |  \n| `Browsers::OPERA` |  Opera |  \n| `Browsers::PUFFIN` |  Puffin |  \n| `Browsers::SAFARI` |  Safari |  \n| `Browsers::SAILFISHBROWSER` |  SailfishBrowser |  \n| `Browsers::SAMSUNGBROWSER` |  SamsungBrowser |  \n| `Browsers::SILK` |  Silk |  \n| `Browsers::SLACKBOT` |  Slackbot |  \n| `Browsers::TELEGRAMBOT` |  TelegramBot |  \n| `Browsers::TIZENBROWSER` |  TizenBrowser |  \n| `Browsers::TWITTERBOT` |  Twitterbot |  \n| `Browsers::UC_BROWSER` |  UC Browser |  \n| `Browsers::VALVE_STEAM_TENFOOT` |  Valve Steam Tenfoot |  \n| `Browsers::VIVALDI` |  Vivaldi |  \n| `Browsers::WGET` |  Wget |  \n| `Browsers::WHALE` |  Whale |  \n| `Browsers::WORDPRESS` |  WordPress |  \n| `Browsers::YANDEX` |  Yandex |  \n| `Browsers::YANDEXBOT` |  YandexBot |\n\nMore information is available at [Donat Studios](https://donatstudios.com/PHP-Parser-HTTP_USER_AGENT).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonatj%2FPhpUserAgent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdonatj%2FPhpUserAgent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonatj%2FPhpUserAgent/lists"}