{"id":13545514,"url":"https://github.com/hisorange/browser-detect","last_synced_at":"2025-05-14T08:08:21.271Z","repository":{"id":12336114,"uuid":"14976714","full_name":"hisorange/browser-detect","owner":"hisorange","description":"Browser Detection for Laravel by hisorange!","archived":false,"fork":false,"pushed_at":"2024-12-10T00:26:47.000Z","size":1198,"stargazers_count":1119,"open_issues_count":17,"forks_count":144,"subscribers_count":27,"default_branch":"stable","last_synced_at":"2025-05-09T03:39:10.351Z","etag":null,"topics":["bot-detection","crawler-detection","laravel","mobile-detection","user-agent","user-agent-parser"],"latest_commit_sha":null,"homepage":"https://browser-detect.com","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/hisorange.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-12-06T07:38:27.000Z","updated_at":"2025-05-01T19:48:40.000Z","dependencies_parsed_at":"2024-06-18T10:50:43.181Z","dependency_job_id":"e4b1a391-82db-4b33-b80d-162b34068a97","html_url":"https://github.com/hisorange/browser-detect","commit_stats":{"total_commits":370,"total_committers":29,"mean_commits":"12.758620689655173","dds":0.5378378378378379,"last_synced_commit":"b0fe114312617386655c845712b2e5a6a95fb82d"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hisorange%2Fbrowser-detect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hisorange%2Fbrowser-detect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hisorange%2Fbrowser-detect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hisorange%2Fbrowser-detect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hisorange","download_url":"https://codeload.github.com/hisorange/browser-detect/tar.gz/refs/heads/stable","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101558,"owners_count":22014908,"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":["bot-detection","crawler-detection","laravel","mobile-detection","user-agent","user-agent-parser"],"created_at":"2024-08-01T11:01:04.564Z","updated_at":"2025-05-14T08:08:16.262Z","avatar_url":"https://github.com/hisorange.png","language":"PHP","funding_links":[],"categories":["PHP","字符串( Strings )"],"sub_categories":[],"readme":"![Browser Detection Logo](https://user-images.githubusercontent.com/3441017/126362397-d9767164-4f44-4d41-a3cd-b669e10e95dc.png)\n\n## Browser Detection v5.0 by _[hisorange](https://hisorange.me)_\n\n[![Latest Stable Version](https://poser.pugx.org/hisorange/browser-detect/v/stable)](https://packagist.org/packages/hisorange/browser-detect)\n[![Build](https://github.com/hisorange/browser-detect/actions/workflows/latest.yml/badge.svg?branch=stable)](https://github.com/hisorange/browser-detect/actions/workflows/latest.yml)\n[![Coverage Status](https://coveralls.io/repos/github/hisorange/browser-detect/badge.svg)](https://coveralls.io/github/hisorange/browser-detect)\n[![Total Downloads](https://poser.pugx.org/hisorange/browser-detect/downloads)](https://packagist.org/packages/hisorange/browser-detect)\n[![License](https://poser.pugx.org/hisorange/browser-detect/license)](https://packagist.org/packages/hisorange/browser-detect)\n\nEasy to use package to identify the visitor's browser details and device type.\nMagic is **not** involved the results are generated by multiple well tested and developed packages.\n\nSupports **every Laravel** version between **4.0 \u0026raquo; 10.x**;\nAlso tested on **every PHP** version between **5.6 \u0026raquo; 8.2**.\n\n### How to install\n\n---\n\n```sh\ncomposer require hisorange/browser-detect\n```\n\nYep, it's ready to be used by You! ^.^\n\n### How to use\n\n---\n\nIn Your code just call the **Browser** facade:\n\n```php\nuse Browser;\n\n// Determine the user's device type is simple as this:\n$isMobile = Browser::isMobile();\nBrowser::isTablet();\nBrowser::isDesktop();\n\nif (Browser::isMobile()) {\n  // Redirect to the mobile version of the site.\n}\n\n// Every wondered if it is a bot who loading Your page?\nif (Browser::isBot()) {\n    echo 'No need to wonder anymore!';\n}\n\n// Check for common vendors.\nif (Browser::isFirefox() || Browser::isOpera()) {\n    $response .= '\u003cscript src=\"firefox-fix.js\"\u003e\u003c/script\u003e';\n}\n\n// Sometimes You may want to serve different content based on the OS.\nif (Browser::isAndroid()) {\n    $response .= '\u003ca\u003eInstall our Android App!\u003c/a\u003e';\n} elseif (Browser::isMac() \u0026\u0026 Browser::isMobile()) {\n    $response .= '\u003ca\u003eInstall our iOS App!\u003c/a\u003e';\n}\n```\n\nEven in Your blade templates:\n\n```blade\n@mobile\n    \u003cp\u003eThis is the MOBILE template!\u003c/p\u003e\n    @include('your-mobile-template')\n@endmobile\n\n@tablet\n    \u003cp\u003eThis is the TABLET template!\u003c/p\u003e\n    \u003clink rel=\"stylesheet\" href=\"tablet.css\" title=\"Reduce the page size, load what the user need\"\u003e\n@endtablet\n\n@desktop\n    \u003cp\u003eThis is the DESKTOP template!\u003c/p\u003e\n@enddesktop\n\n{-- Every result key is supported --}\n@browser('isBot')\n    \u003cp\u003eBots are identified too :)\u003c/p\u003e\n@endbrowser\n```\n\nEasy peasy, ain't it?\n\n### Version support\n\n---\n\nThe following matrix has been continuously tested by the great and awesome **GitHub Actions**!\n\n|    -----     | Browser Detect 1.x | Browser Detect 2.x | Browser Detect 3.x | Browser Detect 4.x | Browser Detect 5.x |\n| :----------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: |\n| Laravel 4.x  |      \u0026#10003;      |      \u0026#10003;      |         -          |         -          |         -          |\n| Laravel 5.x  |         -          |      \u0026#10003;      |      \u0026#10003;      |         -          |         -          |\n| Laravel 6.x  |         -          |         -          |         -          |      \u0026#10003;      |         -          |\n| Laravel 7.x  |         -          |         -          |         -          |      \u0026#10003;      |         -          |\n| Laravel 8.x  |         -          |         -          |         -          |        4.4+        |         -          |\n| Laravel 9.x  |         -          |         -          |         -          |        4.4+        |      \u0026#10003;      |\n| Laravel 10.x |         -          |         -          |         -          |         -          |      \u0026#10003;      |\n|  Standalone  |         -          |         -          |         -          |        4.2+        |      \u0026#10003;      |\n\nSince 2013 the package runs tests on every possible PHP / Laravel version matrix.\n\n### Standalone mode, without Laravel!\n\n---\n\nBased on community requests; Now You can use the library without Laravel.\nJust simply use the Parser class as a static object.\n\n```php\nuse hisorange\\BrowserDetect\\Parser as Browser;\n\nif (Browser::isLinux()) {\n    // Works as well!\n}\n```\n\n### Available API calls\n\n---\n\nEvery call on the **Browser** facade is proxied to a result object, so the following information are available on Your result too, where You can use the \\[array\\] syntax to access them.\n\n| Call                                    | Response                                                                | Internal Type |\n| :-------------------------------------- | :---------------------------------------------------------------------- | :-----------: |\n| Browser::userAgent()                    | Current visitor's HTTP_USER_AGENT string.                               |  _(string)_   |\n| Browser::isMobile()                     | Is this a mobile device.                                                |  _(boolean)_  |\n| Browser::isTablet()                     | Is this a tablet device.                                                |  _(boolean)_  |\n| Browser::isDesktop()                    | Is this a desktop computer.                                             |  _(boolean)_  |\n| Browser::isBot()                        | Is this a crawler / bot.                                                |  _(boolean)_  |\n| Browser::deviceType()                   | Enumerated response for [Mobile, Tablet, Desktop, and Bot]              |  _(string)_   |\n| **Browser related functions**           |                                                                         |               |\n| Browser::browserName()                  | Browser's human friendly name like Firefox 3.6, Chrome 42.              |  _(string)_   |\n| Browser::browserFamily()                | Browser's vendor like Chrome, Firefox, Opera.                           |  _(string)_   |\n| Browser::browserVersion()               | Browser's human friendly version string.                                |  _(string)_   |\n| Browser::browserVersionMajor()          | Browser's [semantic](https://semver.org/) major version.                |  _(integer)_  |\n| Browser::browserVersionMinor()          | Browser's [semantic](https://semver.org/) minor version.                |  _(integer)_  |\n| Browser::browserVersionPatch()          | Browser's [semantic](https://semver.org/) patch version.                |  _(integer)_  |\n| Browser::browserEngine()                | Browser's engine like: Blink, WebKit, Gecko.                            |  _(string)_   |\n| **Operating system related functions**  |                                                                         |               |\n| Browser::platformName()                 | Operating system's human friendly name like Windows XP, Mac 10.         |  _(string)_   |\n| Browser::platformFamily()               | Operating system's vendor like Linux, Windows, Mac.                     |  _(string)_   |\n| Browser::platformVersion()              | Operating system's human friendly version like XP, Vista, 10.           |  _(integer)_  |\n| Browser::platformVersionMajor()         | Operating system's [semantic](https://semver.org/) major version.       |  _(integer)_  |\n| Browser::platformVersionMinor()         | Operating system's [semantic](https://semver.org/) minor version.       |  _(integer)_  |\n| Browser::platformVersionPatch()         | Operating system's [semantic](https://semver.org/) patch version.       |  _(integer)_  |\n| **Operating system extended functions** |                                                                         |               |\n| Browser::isWindows()                    | Is this a windows operating system.                                     |  _(boolean)_  |\n| Browser::isLinux()                      | Is this a linux based operating system.                                 |  _(boolean)_  |\n| Browser::isMac()                        | Is this an iOS or Mac based operating system.                           |  _(boolean)_  |\n| Browser::isAndroid()                    | Is this an Android operating system.                                    |  _(boolean)_  |\n| **Device related functions**            |                                                                         |               |\n| Browser::deviceFamily()                 | Device's vendor like Samsung, Apple, Huawei.                            |  _(string)_   |\n| Browser::deviceModel()                  | Device's brand name like iPad, iPhone, Nexus.                           |  _(string)_   |\n| **Browser vendor related functions**    |                                                                         |               |\n| Browser::isChrome()                     | Is this a chrome browser.                                               |  _(boolean)_  |\n| Browser::isFirefox()                    | Is this a firefox browser.                                              |  _(boolean)_  |\n| Browser::isOpera()                      | Is this an opera browser.                                               |  _(boolean)_  |\n| Browser::isSafari()                     | Is this a safari browser.                                               |  _(boolean)_  |\n| Browser::isIE()                         | Checks if the browser is an some kind of Internet Explorer (or Trident) |  _(boolean)_  |\n| Browser::isIEVersion()                  | Compares to a given IE version                                          |  _(boolean)_  |\n| Browser::isEdge()                       | Is this a microsoft edge browser.                                       |  _(boolean)_  |\n| **Miscellaneous**                       |                                                                         |               |\n| Browser::isInApp()                      | Check for browsers rendered inside applications like android webview.   |  _(boolean)_  |\n\n### Configuration, personalization\n\n---\n\nIf You are using Laravel then after installation run the following command:\n\n```sh\n# Will copy a config file to ~/app/config/browser-detect.php\nphp artisan vendor:publish\n```\n\nFor standalone mode to apply Your custom configuration:\n\n```php\nuse hisorange\\BrowserDetect\\Parser;\n\n$browser = new Parser(null, null, [\n    'cache' =\u003e [\n        'interval' =\u003e 86400 // This will override the default configuration.\n    ]\n]);\n\n$result = $browser-\u003edetect();\n```\n\nSince the package aims to be easy to use, there is not much to configure.\nBut You can customize the cache and security values.\n\n### Advanced Usage Information\n\n---\n\nThe code is designed to be an easy to use style,\nso every call You make on the **Browser** facade will access the result object and get the data for You,\nbut You can parse agents other than the current user's.\n\n```php\n// When You call the detect function You will get a result object, from the current user's agent.\n$result = Browser::detect();\n\n// If You wanna get browser details from a user agent other than the current user call the parse function.\n$result = Browser::parse('Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14');\n```\n\nWorthy notion! The parser only parsing each user agent string once and then caches it,\nit uses an in-memory runtime cache for multiple calls in a single page load;\nAnd it will use the application's cache to persist the result for a week or so,\nthis should provide You with a sufficient caching mechanism so the detection will\ncost less than **0.02 millisecond**, this was tested with an 80,000 fake visit.\n\n### Changelog\n\n---\n\nSee the detailed changes in the [CHANGELOG](CHANGELOG.md) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhisorange%2Fbrowser-detect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhisorange%2Fbrowser-detect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhisorange%2Fbrowser-detect/lists"}