Symfony2 Bundle to access the browscap information
PHP
Latest commit 58e71da Apr 11, 2014 @JoshuaEstes JoshuaEstes Merge pull request #7 from JoshuaEstes/6-composer-problem
Update to fix issues with future versions of symfony
Permalink
Failed to load latest commit information.
Command
DependencyInjection
Resources/config added silent property to options Jan 3, 2014
Tests
.gitignore
.scrutinizer.yml Added Travis and Scrutinizer configs Mar 10, 2014
.travis.yml
Browscap.php updated readme with some info and update the namespaces for all files Jan 17, 2013
BrowscapBundle.php updated readme with some info and update the namespaces for all files Jan 17, 2013
README.md Added badges for Travis and Scrutinizer Mar 10, 2014
composer.json Update to fix issues with future versions of symfony Apr 11, 2014
composer.lock
phpunit.xml.dist

README.md

Browscap/BrowscapBundle

Build Status Scrutinizer Quality Score Code Coverage

This is a service for you that is similar to the php fucntion get_browser(). It uses https://github.com/GaretJax/phpbrowscap project.

Installation

php composer.phar require browscap/browscap-bundle:1.0.*

This will install the current version which is beta and is the master branch. I don't want to say it's stable yet until I have some more tests and real world usage under the belt, but should be good enough to use in a production site.

In your app/AppKernel.php file

public function registerBundles()
{
    ...
    $bundles = array(
        ...
        new Browscap\BrowscapBundle\BrowscapBundle(),
        ...
    );
    ...
}

Configuration

You can see the configuration values and information by running php app/console config:dump-reference BrowscapBundle

browscap:
    remote_ini_url:       http://tempdownloads.browserscap.com/stream.php?BrowsCapINI
    remote_ver_url:       http://tempdownloads.browserscap.com/versions/version-date.php
    cache_dir:            null # If null, use your application cache directory
    timeout:              5
    update_interval:      432000
    error_interval:       7200
    do_auto_update:       true
    update_method:        'cURL' # Supported methods: 'URL-wrapper','socket','cURL' and 'local'.
    local_file:           null # Only if used
    cache_filename:       'cache.php'
    ini_filename:         'browscap.ini'
    lowercase:            false # You need to rebuild the cache if this option is changed
    silent:               false

Usage

In your controller, you will just need to get the browser information via the dependency injection container.

// @var $browscap \Browscap\BrowscapBundle\Browscap
$browscap = $this->container->get('browscap');
$browser = $browscap->getBrowser();

In the future there might be some more functions.