mimmi20/browser-detector
Library to detect Browsers and Devices
4.0.0
2018-04-15 14:51 UTC
Requires
- php: ^7.1
- danielstjules/stringy: ^3.0
- mimmi20/browser-detector-loader-interface: ~2.0.5
- mimmi20/browser-detector-version: ~5.0.1
- mimmi20/ua-browser-type: ~6.0.1
- mimmi20/ua-device-type: ~6.0.0
- mimmi20/ua-generic-request: ^3.0.1
- mimmi20/ua-normalizer: ^3.0.0
- mimmi20/ua-result: ~5.2.3
- mimmi20/ua-result-company: ~3.2.7
- peterkahl/apple-ios-build-version: 43.0
- peterkahl/apple-os-x-build-version: 37.1
- psr/http-message: ^1.0
- psr/log: ^1.0
- psr/simple-cache: ^1.0
- seld/jsonlint: ^1.7
- symfony/finder: ^3.3 || ^4.0
- symfony/yaml: ^3.3 || ^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.11
- localheinz/composer-normalize: ^0.6.0
- monolog/monolog: ^1.23
- phpstan/phpstan: ^0.9
- phpunit/phpunit: ^6.5 || ^7.0
- squizlabs/php_codesniffer: ^3.2
- symfony/cache: ^3.3 || ^4.0
- zendframework/zend-diactoros: ^1.7
- dev-master
- 4.0.0
- 3.1.11
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.0
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.2.0-beta
- 0.1.0-alpha
- dev-add-new-devices
README
Code Status
Requirements
This library requires PHP 7.1+. Also a PSR-3 compatible logger and a PSR-16 compatible cache are required.
Installation
Run the command below to install via Composer
composer require mimmi20/browser-detector
Preparation
Before you can use this library, you have to warmup the cache. This should be done not in the same process like the detection.
$detector = new \BrowserDetector\Detector($cache, $logger); $detector->warmupCache();
Usage
$detector = new \BrowserDetector\Detector($cache, $logger); // generic call (deprecated) $result = $detector->getBrowser($request); // call depending on the data $result = $detector->parseString($request); $result = $detector->parseArray($request); $result = $detector->parseMessage($request); // for a PSR7 MessageInterface
The request parameter may be a string, an array or a PSR-7 compatible message.
Usage Examples
Taking the user agent from the global $_SERVER variable
$detector = new \BrowserDetector\Detector($cache, $logger); // generic call (deprecated) $result = $detector->getBrowser($_SERVER); // call depending on the data $result = $detector->parseArray($_SERVER);
Using a sample useragent
$detector = new \BrowserDetector\Detector($cache, $logger); // generic call (deprecated) $result = $detector->getBrowser($the_user_agent); // call depending on the data $result = $detector->parseString($the_user_agent);
The result
The getBrowser
function and the parse*
functions return a ua-result object.
Issues and feature requests
Please report your issues and ask for new features on the GitHub Issue Tracker at https://github.com/mimmi20/BrowserDetector/issues