https://github.com/reiniiriarios/useragent-parser
User agent parser that returns vaguely useful browser and OS information. Primarily useful for icon generation and broad filtering, such as in log reports.
https://github.com/reiniiriarios/useragent-parser
user-agent user-agent-parser
Last synced: 2 months ago
JSON representation
User agent parser that returns vaguely useful browser and OS information. Primarily useful for icon generation and broad filtering, such as in log reports.
- Host: GitHub
- URL: https://github.com/reiniiriarios/useragent-parser
- Owner: reiniiriarios
- License: gpl-3.0
- Created: 2021-03-11T01:24:12.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-03T20:46:19.000Z (about 5 years ago)
- Last Synced: 2025-12-19T20:11:52.117Z (6 months ago)
- Topics: user-agent, user-agent-parser
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# useragent-parser
User agent parser that returns vaguely useful browser and OS information. Rather than aim for comprehensiveness, this aims only to return broad information on the most common devices, browsers, hardware, etc.
Most useful when utilizing `get_icon($type)` or `get_all_icons()`.
## Usage
### Configuring
Set `$ua->assets_uri` to path to icon pngs. (Default: `/assets/ua/`)
### Result Types
* Operating System `os`
* e.g. Windows, macOS
* Browser `browser`
* e.g. Firefox, Safari, Firefox iOS
* Hardware `hardware`
* e.g. Nintendo Switch, Apple iPad
* Miscellaneous `misc`
* e.g. Slack, WhatsApp, Gmail, cURL, Python-urllib
* Bot `bot`
* e.g. Googlebot, BingBot, Baidu Spider
### Result Data
* Name
* Icon
* Version
* Brand (hardware only)
* Model (hardware only)
* Mobile (boolean, can be inaccurate)
```php
$user_agent = new \reiniiriarios\Useragent\Parser($user_agent_string);
$user_agent_info = $user_agent->parse();
$user_agent_os = $user_agent->parse('os');
$browser_icon = $user_agent->get_icon('browser');
/*
$user_agent_info = [
'os' => [
'name' => 'Windows',
'icon' => 'win10',
'version' => '10'
],
'browser' => [
'name' => 'Firefox',
'icon' => 'firefox',
'version' => '86.0'
],
'hardware' => false,
'misc' => false,
'bot' => false
];
$user_agent_os = [
'name' => 'Windows',
'icon' => 'win10',
'version' => '10'
];
$browser_icon = '
';
*/
```