{"id":13398201,"url":"https://github.com/jenssegers/agent","last_synced_at":"2025-12-16T17:36:44.136Z","repository":{"id":9988374,"uuid":"12018530","full_name":"jenssegers/agent","owner":"jenssegers","description":"👮 A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect","archived":false,"fork":false,"pushed_at":"2024-08-05T12:34:44.000Z","size":232,"stargazers_count":4628,"open_issues_count":82,"forks_count":537,"subscribers_count":89,"default_branch":"master","last_synced_at":"2025-05-08T09:42:14.485Z","etag":null,"topics":["accept-language","browser","mobile-detect","platform","robot","user-agent"],"latest_commit_sha":null,"homepage":"https://jenssegers.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"wting/autojump","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jenssegers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"jenssegers","tidelift":"packagist/jenssegers/agent"}},"created_at":"2013-08-10T09:19:59.000Z","updated_at":"2025-05-06T18:17:39.000Z","dependencies_parsed_at":"2023-11-07T17:11:30.374Z","dependency_job_id":"6c1b72d6-a619-4f76-a9f4-7c5707da511f","html_url":"https://github.com/jenssegers/agent","commit_stats":{"total_commits":166,"total_committers":29,"mean_commits":5.724137931034483,"dds":0.3855421686746988,"last_synced_commit":"1d91c71bc076a60061e0498216c0caf849eced94"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenssegers%2Fagent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenssegers%2Fagent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenssegers%2Fagent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenssegers%2Fagent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenssegers","download_url":"https://codeload.github.com/jenssegers/agent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253115655,"owners_count":21856716,"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":["accept-language","browser","mobile-detect","platform","robot","user-agent"],"created_at":"2024-07-30T19:00:20.005Z","updated_at":"2025-12-16T17:36:44.039Z","avatar_url":"https://github.com/jenssegers.png","language":"PHP","readme":"Agent\n=====\n\n[![Latest Stable Version](http://img.shields.io/packagist/v/jenssegers/agent.svg)](https://packagist.org/packages/jenssegers/agent) [![Total Downloads](http://img.shields.io/packagist/dm/jenssegers/agent.svg)](https://packagist.org/packages/jenssegers/agent) [![Build Status](http://img.shields.io/travis/jenssegers/agent.svg)](https://travis-ci.org/jenssegers/agent) [![Coverage Status](http://img.shields.io/coveralls/jenssegers/agent.svg)](https://coveralls.io/r/jenssegers/agent) [![Donate](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.me/jenssegers)\n\nA PHP desktop/mobile user agent parser with support for Laravel, based on [Mobile Detect](https://github.com/serbanghita/Mobile-Detect) with desktop support and additional functionality.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://jenssegers.com/static/media/agent.png\" height=\"275\"\u003e\n\u003c/p\u003e\n\nInstallation\n------------\n\nInstall using composer:\n\n```bash\ncomposer require jenssegers/agent\n```\n\nLaravel (optional)\n------------------\n\nAdd the service provider in `config/app.php`:\n\n```php\nJenssegers\\Agent\\AgentServiceProvider::class,\n```\n\nAnd add the Agent alias to `config/app.php`:\n\n```php\n'Agent' =\u003e Jenssegers\\Agent\\Facades\\Agent::class,\n```\n\nBasic Usage\n-----------\n\nStart by creating an `Agent` instance (or use the `Agent` Facade if you are using Laravel):\n\n```php\nuse Jenssegers\\Agent\\Agent;\n\n$agent = new Agent();\n```\n\nIf you want to parse user agents other than the current request in CLI scripts for example, you can use the `setUserAgent` and `setHttpHeaders` methods:\n\n```php\n$agent-\u003esetUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2');\n$agent-\u003esetHttpHeaders($headers);\n```\n\nAll of the original [Mobile Detect](https://github.com/serbanghita/Mobile-Detect) methods are still available, check out some original examples at https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples\n\n### Is?\n\nCheck for a certain property in the user agent.\n\n```php\n$agent-\u003eis('Windows');\n$agent-\u003eis('Firefox');\n$agent-\u003eis('iPhone');\n$agent-\u003eis('OS X');\n```\n\n### Magic is-method\n\nMagic method that does the same as the previous `is()` method:\n\n```php\n$agent-\u003eisAndroidOS();\n$agent-\u003eisNexus();\n$agent-\u003eisSafari();\n```\n\n### Mobile detection\n\nCheck for mobile device:\n\n```php\n$agent-\u003eisMobile();\n$agent-\u003eisTablet();\n```\n\n### Match user agent\n\nSearch the user agent with a regular expression:\n\n```php\n$agent-\u003ematch('regexp');\n```\n\nAdditional Functionality\n------------------------\n\n### Accept languages\n\nGet the browser's accept languages. Example:\n\n```php\n$languages = $agent-\u003elanguages();\n// ['nl-nl', 'nl', 'en-us', 'en']\n```\n\n### Device name\n\nGet the device name, if mobile. (iPhone, Nexus, AsusTablet, ...)\n\n```php\n$device = $agent-\u003edevice();\n```\n\n### Operating system name\n\nGet the operating system. (Ubuntu, Windows, OS X, ...)\n\n```php\n$platform = $agent-\u003eplatform();\n```\n\n### Browser name\n\nGet the browser name. (Chrome, IE, Safari, Firefox, ...)\n\n```php\n$browser = $agent-\u003ebrowser();\n```\n\n### Desktop detection\n\nCheck if the user is using a desktop device.\n\n```php\n$agent-\u003eisDesktop();\n```\n\n*This checks if a user is not a mobile device, tablet or robot.*\n\n### Phone detection\n\nCheck if the user is using a phone device.\n\n```php\n$agent-\u003eisPhone();\n```\n\n### Robot detection\n\nCheck if the user is a robot. This uses [jaybizzle/crawler-detect](https://github.com/JayBizzle/Crawler-Detect) to do the actual robot detection.\n\n```php\n$agent-\u003eisRobot();\n```\n\n### Robot name\n\nGet the robot name.\n\n```php\n$robot = $agent-\u003erobot();\n```\n\n### Browser/platform version\n\nMobileDetect recently added a `version` method that can get the version number for components. To get the browser or platform version you can use:\n\n```php\n$browser = $agent-\u003ebrowser();\n$version = $agent-\u003eversion($browser);\n\n$platform = $agent-\u003eplatform();\n$version = $agent-\u003eversion($platform);\n```\n\n*Note, the version method is still in beta, so it might not return the correct result.*\n\n## License\n\nLaravel User Agent is licensed under [The MIT License (MIT)](LICENSE).\n\n## Security contact information\n\nTo report a security vulnerability, follow [these steps](https://tidelift.com/security).\n","funding_links":["https://github.com/sponsors/jenssegers","https://tidelift.com/funding/github/packagist/jenssegers/agent","https://www.paypal.me/jenssegers","https://tidelift.com/security"],"categories":["PHP","目录","Table of Contents","后端开发框架及项目","📌 Covered Topics","字符串( Strings )","字符串 Strings"],"sub_categories":["字符串 Strings","Strings","PHP开发"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenssegers%2Fagent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenssegers%2Fagent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenssegers%2Fagent/lists"}