Developed with love by KnpLabs Hire us for your project!
28

BrowscapBundle

by browscap

Symfony2 Bundle to access the browscap information

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.

browscap:
cache_dir: ~
local_file: ~
cache_filename: cache.php
ini_filename: browscap.ini
remote_ini_url: http://browscap.org/stream?q=Full_PHP_BrowsCapINI
remote_ver_url: http://browscap.org/version
lowercase: false
silent: false
timeout: 5
update_interval: 432000
error_interval: 7200
do_auto_update: true
update_method: cURL
  • Merge pull request #7 from JoshuaEstes/6-composer-problem
    By JoshuaEstes, 3 years ago
  • Update to fix issues with future versions of symfony
    By JoshuaEstes, 3 years ago
  • Added badges for Travis and Scrutinizer
    By asgrim, 3 years ago
  • Merge pull request #5 from Spomky/Tests
    By asgrim, 3 years ago
  • Added Travis and Scrutinizer configs
    By asgrim, 3 years ago
  • Tests added
    By Florent Morselli, 3 years ago
  • Merge pull request #4 from Spomky/Update-command
    By asgrim, 3 years ago
  • Merge pull request #3 from Spomky/Full-configuration
    By asgrim, 3 years ago
  • Merge pull request #2 from Spomky/browscap-php-tags
    By asgrim, 3 years ago
  • Default values updated
    By Spomky, 3 years ago
  • Merge pull request #1 from smatyas/silent-option
    By Spomky, 3 years ago
  • added silent property to options
    By smatyas, 3 years ago
  • Options added
    By Spomky, 4 years ago
  • Unused statement removed
    By Spomky, 4 years ago
  • Cache dir control removed
    By Spomky, 4 years ago
  • Cache version and update commands
    By Spomky, 4 years ago
  • Required version updated
    By Spomky, 4 years ago
  • Documentation updated
    By Spomky, 4 years ago
  • Configuration updated
    By Spomky, 4 years ago
  • bug fix
    By JoshuaEstes, 4 years ago
  • updated readme with some info and update the namespaces for all files
    By Joshua Estes, 4 years ago
  • Renamed readme file
    By Joshua Estes, 4 years ago
  • updated readme file
    By Joshua Estes, 5 years ago
  • updated some of the links and updated so the links can be configured
    By Joshua Estes, 5 years ago
  • moving some files around and updating some documentation, increased version to 0.2.x
    By Joshua Estes, 5 years ago
  • updated a few things in the services.xml file
    By Joshua Estes, 5 years ago
  • added readme file
    By JoshuaEstes, 5 years ago
  • updated the services to just use kernel.cache_dir and updated the browscap file with some wraper functions
    By JoshuaEstes, 5 years ago
  • too tiried
    By JoshuaEstes, 5 years ago
  • bug fix
    By JoshuaEstes, 5 years ago