2017 © Pedro PelĂĄez
 

symfony-bundle browser-detector-bundle

Elao Browser Detector Bundle

image

elao/browser-detector-bundle

Elao Browser Detector Bundle

  • Tuesday, November 3, 2015
  • by Elao
  • Repository
  • 18 Watchers
  • 17 Stars
  • 2,027 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 11 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

Elao BrowserDetector Bundle

Deprecated : please use https://github.com/piwik/device-detector instead.

Changelog

  • 1.1.0
    • BrowserCap and Browser ar now in a separate ElaoBrowserDetector component
    • Rename some parameters
    • Fix composer

Installation:

Require the bundle via composer:, (*1)

"require": {
    "elao/browser-detector-bundle": "1.1.*"
}

Add the bundle to your AppKernel.php:, (*2)

new Elao\Bundle\BrowserDetectorBundle\ElaoBrowserDetectorBundle()

Configuration:

Register the browsers that are not and/or partially supported by your application:, (*3)

elao_browser_detector:
    browsers:
        partially_compatible:
            "Internet Explorer": "<9"
            "Opera": ~
        incompatible:
            "IE": "<=7"

Accepted version format:, (*4)

  • none : any version number, ex: "Firefox": ~ (any Firefox version will match)
  • 'n' : exact version number, ex: "Firefox": '3.6' (only Firefox 3.6 will match)
  • '>n' : strictly later, ex: "Firefox": '>3.6' (Firefox 3.6 will not match, Firefox 3.7 will)
  • '<n' : strictly earlier, ex: "Firefox": '<3.6' (Firefox 3.6 will not match, Firefox 3.5 will)
  • '>=n' : equal or later version, ex: "Firefox": '>=3.6' (Firefox 3.6 and 3.7 will match)
  • '<=n' : equal or earlier version, ex: "Firefox": '<=3.6' (Firefox 3.6 and 3.5 will match)

How it works:

  • The bundle listen to the kernel.request event.
  • It gets the user-agent http header directive from the request on each master request.
  • It use the php get_browser function (based on the browscap.ini file) to detect wich browser is used.
  • It instantiate an Elao\BrowserDetector\Browser object that will resolve compatibility of the current browser based your configuration.

Usage:

The BrowserDetector service

Get the BrowserDetector service or have it injected in your service: elao.browser_detector, (*5)

$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:, (*6)

// Compatibility issers :
$browserDetector->isCompatible();
$browserDetector->isPartiallyCompatible();
$browserDetector->isIncompatible();

Accessing the current Browser instance

If needed, you can work with the Browser object that provide a various set of helpers methods:, (*7)

// 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)

The Versions

03/11 2015

dev-master

9999999-dev

Elao Browser Detector Bundle

  Sources   Download

MIT

The Requires

 

browser detection user-agent browscap

23/01 2015

1.1.2

1.1.2.0

Elao Browser Detector Bundle

  Sources   Download

MIT

The Requires

 

browser detection user-agent browscap

23/01 2015

dev-develop

dev-develop

Elao Browser Detector Bundle

  Sources   Download

MIT

The Requires

 

browser detection user-agent browscap

27/05 2014

1.1.1

1.1.1.0

Elao Browser Detector Bundle

  Sources   Download

MIT

The Requires

 

browser detection user-agent browscap

19/03 2014

1.1.0

1.1.0.0

Elao Browser Detector Bundle

  Sources   Download

MIT

The Requires

 

browser detection user-agent browscap