{"id":25470232,"url":"https://github.com/thinkphp/http-user-agent","last_synced_at":"2025-10-17T23:00:03.287Z","repository":{"id":66903039,"uuid":"1477646","full_name":"thinkphp/http-user-agent","owner":"thinkphp","description":"Browser detection in PHP5. Uses a simple and fast algorithm to recognize major browsers.","archived":false,"fork":false,"pushed_at":"2011-03-14T09:44:10.000Z","size":97,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T14:54:25.734Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://thinkphp.ro/apps/php-hacks/http-user-agent/UserAgentTest.php","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thinkphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-03-14T09:33:55.000Z","updated_at":"2021-04-01T11:55:56.000Z","dependencies_parsed_at":"2023-02-20T14:00:22.961Z","dependency_job_id":null,"html_url":"https://github.com/thinkphp/http-user-agent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fhttp-user-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fhttp-user-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fhttp-user-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fhttp-user-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinkphp","download_url":"https://codeload.github.com/thinkphp/http-user-agent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239437336,"owners_count":19638472,"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":"2025-02-18T08:32:26.176Z","updated_at":"2025-10-17T23:00:03.212Z","avatar_url":"https://github.com/thinkphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PHP User Agent\n--------------\n\nBrowser detection in PHP5. Uses a simple and fast algorithm to recognize major browsers.\n\nHow to use\n==========\n\n    require_once('userAgent.class.php');\n\n    //create an object $userAgent\n    $userAgent = new UserAgent();\n\n    //interrogate userAgent\n    echo$userAgent-\u003egetBrowserName(). ' | '; \n    echo$userAgent-\u003egetBrowserVersion(). ' | ';\n    echo$userAgent-\u003egetOperatingSystem(). ' | ';\n    echo$userAgent-\u003egetEngine();\n\n    /* output:\n       firefox | 3.6 | Windows | gecko  \n     */ \n\nAdvanced\n========\n\n##Custom user agent string\n\nWhen you create a UserAgent object, the current user agent string is used, namely $_SERVER['HTTP_USER_AGENT']. You can specify another user agent string:\n\n       $userAgent = new UserAgent(\"MojeekBot/0.2 (archi; http://www.mojeek.com/bot.html)\");\n       $userAgent-\u003egetBrowserName();//mojeekbot\n       $userAgent-\u003egetBrowserVersion();//0.2\n\n       //use current user agent string\n       $userAgent = new UserAgent($_SERVER['HTTP_USER_AGENT']);\n       //this is equivalent to:\n       $userAgent = new UserAgent();\n\n##Custom parser class\n\nBy default, UserAgentStringParser is used to analyse the user agent string. You can replace the parser instance and customize it to match your needs:\n\n      //create a custom user agent string parser\n      class myCustomUserAgentStringParser extends UserAgentStringParser {\n           //overrides methods\n      }\n\n      //end inject the custom parser when creating user agent\n      $userAgent = new UserAgent(null, myCustomUserAgentParser);\n\n\nWhy you should use it\n---------------------\n\nPHP provides a native function to detect user browser: get_browser() requires the \"browscap.ini\" which is 300KB+. Loading and processing this file impact script performance. And sometimes, the production server just doesn't provide broscap.ini.\nAlthough get_browser() surely provides excellent detection results, in most cases a much simpler can be just as effective. This class\nhas the advantage of being compact and easy to extend. It is performant as well, since it doesn't do any iteration or recurion.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkphp%2Fhttp-user-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkphp%2Fhttp-user-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkphp%2Fhttp-user-agent/lists"}