{"id":20103155,"url":"https://github.com/dotkernel/dot-user-agent-sniffer","last_synced_at":"2025-05-06T08:31:10.392Z","repository":{"id":36219845,"uuid":"221683084","full_name":"dotkernel/dot-user-agent-sniffer","owner":"dotkernel","description":"DotKernel component providing details about a device by parsing a user agent.","archived":false,"fork":false,"pushed_at":"2025-02-21T10:18:01.000Z","size":128,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"3.0","last_synced_at":"2025-04-25T05:38:04.794Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.dotkernel.org/dot-user-agent-sniffer/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotkernel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-14T11:36:07.000Z","updated_at":"2025-02-21T10:16:43.000Z","dependencies_parsed_at":"2024-04-11T04:43:25.517Z","dependency_job_id":"91a7e404-891d-4b86-9fa6-8e002d3a99fd","html_url":"https://github.com/dotkernel/dot-user-agent-sniffer","commit_stats":{"total_commits":17,"total_committers":5,"mean_commits":3.4,"dds":0.7058823529411764,"last_synced_commit":"1b08e41826f5c963bdc3d356b91a04bf33c59b56"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-user-agent-sniffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-user-agent-sniffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-user-agent-sniffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-user-agent-sniffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotkernel","download_url":"https://codeload.github.com/dotkernel/dot-user-agent-sniffer/tar.gz/refs/heads/3.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252648571,"owners_count":21782405,"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":[],"created_at":"2024-11-13T17:34:30.110Z","updated_at":"2025-05-06T08:31:10.384Z","avatar_url":"https://github.com/dotkernel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dot-user-agent-sniffer\n\nDotkernel component based on matomo/device-detector, providing details about a device by parsing a user agent.\n\n\u003e `dotkernel/dot-user-agent-sniffer` is a wrapper on top of [matomo/device-detector](https://github.com/matomo-org/device-detector)\n\n## Documentation\n\nDocumentation is available at: https://docs.dotkernel.org/dot-user-agent-sniffer/.\n\n## Badges\n\n![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-user-agent-sniffer)\n![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-user-agent-sniffer/3.7.0)\n\n[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-user-agent-sniffer)](https://github.com/dotkernel/dot-user-agent-sniffer/issues)\n[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-user-agent-sniffer)](https://github.com/dotkernel/dot-user-agent-sniffer/network)\n[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-user-agent-sniffer)](https://github.com/dotkernel/dot-user-agent-sniffer/stargazers)\n[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-user-agent-sniffer)](https://github.com/dotkernel/dot-user-agent-sniffer/blob/3.0/LICENSE)\n\n[![Build Static](https://github.com/dotkernel/dot-user-agent-sniffer/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-user-agent-sniffer/actions/workflows/continuous-integration.yml)\n[![codecov](https://codecov.io/gh/dotkernel/dot-user-agent-sniffer/graph/badge.svg?token=HZKFRQWDSV)](https://codecov.io/gh/dotkernel/dot-user-agent-sniffer)\n[![PHPStan](https://github.com/dotkernel/dot-user-agent-sniffer/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-user-agent-sniffer/actions/workflows/static-analysis.yml)\n\n## Install\n\nYou can install this library by running the following command:\n\n```shell\ncomposer require dotkernel/dot-user-agent-sniffer\n```\n\nBefore adding this library as a dependency to your service, you need to add `Dot\\UserAgentSniffer\\ConfigProvider::class,` to your application's `config/config.php` file.\n\n## Usage example\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace Api\\Example\\Service;\n\nuse Dot\\UserAgentSniffer\\Data\\DeviceData;\nuse Dot\\UserAgentSniffer\\Service\\DeviceServiceInterface;\n\n/**\n * Class MyService\n * @package Api\\Example\\Service\n */\nclass MyService\n{\n    /** @var DeviceServiceInterface $deviceService */\n    protected $deviceService;\n\n    /**\n     * MyService constructor.\n     * @param DeviceServiceInterface $deviceService\n     */\n    public function __construct(DeviceServiceInterface $deviceService)\n    {\n        $this-\u003edeviceService = $deviceService;\n    }\n\n    /**\n     * @param string $userAgent\n     * @return DeviceData\n     */\n    public function myMethod(string $userAgent)\n    {\n        return $this-\u003edeviceService-\u003egetDetails($userAgent);\n    }\n}\n```\n\nWhen called with an `$userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/78.0.3904.84 Mobile/15E148 Safari/604.1'`, `myMethod($userAgent)` returns an object with the following structure:\n\n```php\nDot\\UserAgentSniffer\\Data\\DeviceData::__set_state(array(\n    'type' =\u003e 'smartphone',\n    'brand' =\u003e 'Apple',\n    'model' =\u003e 'iPhone',\n    'isBot' =\u003e false,\n    'isMobile' =\u003e true,\n    'os' =\u003e\n      Dot\\UserAgentSniffer\\Data\\OsData::__set_state(array(\n        'name' =\u003e 'iOS',\n        'version' =\u003e '13.2',\n        'platform' =\u003e '',\n    )),\n    'client' =\u003e\n      Dot\\UserAgentSniffer\\Data\\ClientData::__set_state(array(\n        'type' =\u003e 'browser',\n        'name' =\u003e 'Chrome Mobile iOS',\n        'engine' =\u003e 'WebKit',\n        'version' =\u003e '78.0',\n    )),\n))\n```\n\nThe above call can also be chained as `myMethod($userAgent)-\u003egetArrayCopy()`, to retrieve the details as an array:\n\n```php\narray (\n    'type' =\u003e 'smartphone',\n    'brand' =\u003e 'Apple',\n    'model' =\u003e 'iPhone',\n    'isMobile' =\u003e true,\n    'isBot' =\u003e false,\n    'os' =\u003e\n      array (\n        'name' =\u003e 'iOS',\n        'version' =\u003e '13.2',\n        'platform' =\u003e '',\n    ),\n    'client' =\u003e\n      array (\n        'type' =\u003e 'browser',\n        'name' =\u003e 'Chrome Mobile iOS',\n        'engine' =\u003e 'WebKit',\n        'version' =\u003e '78.0',\n    ),\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-user-agent-sniffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotkernel%2Fdot-user-agent-sniffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-user-agent-sniffer/lists"}