Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/poowaa/browser-detect-standalone
Browser & Mobile detection package standalone PHP based on hisorange/browser-detect.
https://github.com/poowaa/browser-detect-standalone
Last synced: about 2 months ago
JSON representation
Browser & Mobile detection package standalone PHP based on hisorange/browser-detect.
- Host: GitHub
- URL: https://github.com/poowaa/browser-detect-standalone
- Owner: PoOwAa
- License: mit
- Created: 2019-06-06T13:03:30.000Z (over 5 years ago)
- Default Branch: stable
- Last Pushed: 2019-06-06T17:43:16.000Z (over 5 years ago)
- Last Synced: 2023-12-17T17:48:41.397Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Standalone PHP Browser Detection based on _[hisorange/browser-detect](https://github.com/hisorange/browser-detect)_
Easy to use package to identify the user's browser details and device type. Magic is not involved the results are generated by multiple well tested and developed packages. Supporting every release **PHP** between **5.6 » 7.2**.
### How to install
---
```sh
composer require PoOwAa/browser-detect-standalone
```Yep, that's it!
### How to use
---
If you want to use the user's browser, then simply use the Browser class:
```php
use PoOwAa\BrowserDetect\Browser as Browser;// Determine the user's device type is simple as this:
Browser::isMobile();
Browser::isTablet();
Browser::isDesktop();// Every wondered if it is a bot who loading your page?
if (Browser::isBot()) {
echo 'No need to wonder anymore!';
}// Check for vendors.
if (Browser::isFirefox() || Browser::isOpera()) {
$output .= '';
}
```If you want to handle custom useragent, then use the Parser class:
```php
use PoOwAa\BrowserDetect\Parser;$customBrowser = new PoOwAa\BrowserDetect\Parser('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36');
// Determine the user's device type is simple as this:
$customBrowser->isMobile();
$customBrowser->isTablet();
$customBrowser->isDesktop();// Every wondered if it is a bot who loading your page?
if ($customBrowser->isBot()) {
echo 'No need to wonder anymore!';
}// Check for vendors.
if ($customBrowser->isFirefox() || $customBrowser->isOpera()) {
$output .= '';
}
```### Available API calls
---
Every call on the **Browser** object is mirrored to the result object, so the following informations are available on your result too, where you can use the array syntax to access them.
| Call | Response | Internal Type |
| :------------------------------------- | :---------------------------------------------------------------------- | :-----------: |
| Browser::userAgent() | Current visitor's HTTP_USER_AGENT string. | _(string)_ |
| Browser::isMobile() | Is this a mobile device. | _(boolean)_ |
| Browser::isTablet() | Is this a tablet device. | _(boolean)_ |
| Browser::isDesktop() | Is this a desktop computer. | _(boolean)_ |
| Browser::isBot() | Is this a crawler / bot. | _(boolean)_ |
| **Browser related functions** | | |
| Browser::browserName() | Browser's human friendly name like Firefox 3.6, Chrome 42. | _(string)_ |
| Browser::browserFamily() | Browser's vendor like Chrome, Firefox, Opera. | _(string)_ |
| Browser::browserVersion() | Browser's human friendly version string. | _(string)_ |
| Browser::browserVersionMajor() | Browser's [semantic](https://semver.org/) major version. | _(integer)_ |
| Browser::browserVersionMinor() | Browser's [semantic](https://semver.org/) minor version. | _(integer)_ |
| Browser::browserVersionPatch() | Browser's [semantic](https://semver.org/) patch version. | _(integer)_ |
| Browser::browserEngine() | Browser's engine like: Blink, WebKit, Gecko. | _(string)_ |
| **Operating system related functions** | | |
| Browser::platformName() | Operating system's human friendly name like Windows XP, MacOS 10. | _(string)_ |
| Browser::platformFamily() | Operating system's vendor like Linux, Windows, MacOS. | _(string)_ |
| Browser::platformVersion() | Operating system's human friendly version like XP, Vista, 10. | _(integer)_ |
| Browser::platformVersionMajor() | Operating system's [semantic](https://semver.org/) major version. | _(integer)_ |
| Browser::platformVersionMinor() | Operating system's [semantic](https://semver.org/) minor version. | _(integer)_ |
| Browser::platformVersionPatch() | Operating system's [semantic](https://semver.org/) patch version. | _(integer)_ |
| **Device related functions** | | |
| Browser::deviceFamily() | Device's vendor like Samsung, Apple, Huawei. | _(string)_ |
| Browser::deviceModel() | Device's brand name like iPad, iPhone, Nexus. | _(string)_ |
| Browser::mobileGrade() | Device's mobile grade in scale of A,B,C for performance. | _(string)_ |
| **Browser vendor related functions** | | |
| Browser::isChrome() | Is this a chrome browser. | _(boolean)_ |
| Browser::isFirefox() | Is this a firefox browser. | _(boolean)_ |
| Browser::isOpera() | Is this an opera browser. | _(boolean)_ |
| Browser::isSafari() | Is this a safari browser. | _(boolean)_ |
| Browser::isIE() | Checks if the browser is an some kind of Internet Explorer (or Trident) | _(boolean)_ |
| Browser::isIEVersion() | Compares to a given IE version | _(boolean)_ |
| Browser::isEdge() | Is this a microsoft edge browser. | _(boolean)_ |