Require the bundle via composer:
"require": {
"elao/browser-detector-bundle": "1.1.*"
}
Add the bundle to your AppKernel.php:
new Elao\Bundle\BrowserDetectorBundle\ElaoBrowserDetectorBundle()
Register the browsers that are not and/or partially supported by your application:
elao_browser_detector:
browsers:
partially_compatible:
"Internet Explorer": "<9"
"Opera": ~
incompatible:
"IE": "<=7"
Accepted version format:
Get the BrowserDetector service or have it injected in your service: elao.browser_detector
$browserDetector = $container->get('elao_browser_detector');
// or
<argument type="service" id="elao_browser_detector" />
You're now able to get some compatibility information from the BrowserDetector service:
// Compatibility issers :
$browserDetector->isCompatible();
$browserDetector->isPartiallyCompatible();
$browserDetector->isIncompatible();
If needed, you can work with the Browser object that provide a various set of helpers methods:
// Get the current Browser instance:
$browser = $browserDetector->getBrowser();
// Get the Name of the browser, ex: 'Firefox'
$browser->getName();
// Get the Version of the browser, ex: '22.0'
$browser->getVersion();
// Get the platform of the browser, ex: 'MacOsX'
$browser->getPlatform();
// Compatibility issers:
is(string $name, int $version = null)
isPlatform(string $platform)
isExactly(int $version)
isLaterThan(int $version)
isEqualOrLaterThan(int $version)
isEarlierThan(int $version)
isEqualOrEarlierThan(int $version)