gabrielbull / browser
Detecting the user's browser, operating system and language.
Installs: 436 986
Dependents: 3
Suggesters: 0
Security: 0
Stars: 559
Watchers: 54
Forks: 100
Open Issues: 16
Requires
- php: >=7.2
Requires (Dev)
- phpunit/phpunit: ^8.0 || ^9.4
This package is auto-updated.
Last update: 2022-02-24 15:45:20 UTC
README
Detecting the user's browser, operating system, device and language from PHP. Because browser detection is not always reliable and evolves at all time, use with care and feel free to contribute.
Requirements
This library uses PHP 5.3+.
Install
It is recommended that you install the PHP Browser library through composer. To do so, run the following command:
composer require sinergi/browser-detector
Browser Detection
The Browser class allows you to detect a user's browser and version.
Browsers Detected
- Vivaldi
- Opera
- Opera Mini
- WebTV
- Internet Explorer
- Pocket Internet Explorer
- Microsoft Edge
- Konqueror
- iCab
- OmniWeb
- Firebird
- Firefox
- Iceweasel
- Shiretoko
- Mozilla
- Amaya
- Lynx
- Safari
- Chrome
- Navigator
- GoogleBot
- Yahoo! Slurp
- W3C Validator
- BlackBerry
- IceCat
- Nokia S60 OSS Browser
- Nokia Browser
- MSN Browser
- MSN Bot
- Netscape Navigator
- Galeon
- NetPositive
- Phoenix
- SeaMonkey
- Yandex Browser
- Comodo Dragon
- Samsung Browser
- wkhtmltopdf
Usage
use Sinergi\BrowserDetector\Browser; $browser = new Browser(); if ($browser->getName() === Browser::IE && $browser->getVersion() < 11) { echo 'Please upgrade your browser.'; }
Compatibility Mode
Detect if Internet Explorer is in Compatibility Mode and send the correct header to have the browser render the page in its standard mode. This must be called before any output is sent to the browser.
use Sinergi\BrowserDetector\Browser; $browser = new Browser(); if ($browser->getName() === Browser::IE && $browser->isCompatibilityMode()) { $browser->endCompatibilityMode(); }
OS Detection
The OS class allows you to detect a user's operating system and version.
OS Detected
- Windows
- Windows Phone
- OS X
- iOS
- Android
- Chrome OS
- Linux
- SymbOS
- Nokia
- BlackBerry
- FreeBSD
- OpenBSD
- NetBSD
- OpenSolaris
- SunOS
- OS2
- BeOS
Usage
use Sinergi\BrowserDetector\Os; $os = new Os(); if ($os->getName() === Os::IOS) { echo 'You are using an iOS device.'; }
Device Detection
The Device class allows you to detect a user's device.
Device Detected
- iPad
- iPhone
- Windows Phone
- Lumia
Usage
use Sinergi\BrowserDetector\Device; $device = new Device(); if ($device->getName() === Device::IPAD) { echo 'You are using an iPad.'; }
Language Detection
The Language class allows you to detect a user's language.
Usage
use Sinergi\BrowserDetector\Language; $language = new Language(); if ($language->getLanguage() === 'de') { echo 'Get this website in german.'; }
License
PHP Browser is licensed under The MIT License (MIT).