2017 © Pedro Peláez
 

library zf2-browscap

ZF2 Browscap is a Zend Framework 2 module that provides an improved 'get_browser' function. This module could be standalone if 'browscap' configuration setting in php.ini is undefined or does not point to the correct location of the browscap.ini file

image

neilime/zf2-browscap

ZF2 Browscap is a Zend Framework 2 module that provides an improved 'get_browser' function. This module could be standalone if 'browscap' configuration setting in php.ini is undefined or does not point to the correct location of the browscap.ini file

  • Tuesday, September 17, 2013
  • by Neilime
  • Repository
  • 1 Watchers
  • 2 Stars
  • 2,020 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

ZF2 Browscap

⚠️ This module is for Zend Framework 2, it is deprecated ⚠️, (*1)

Build Status Latest Stable Version Total Downloads Code coverage, (*2)

NOTE : If you want to contribute don't hesitate, I'll review any PR., (*3)

Introduction

ZF2 Browscap is a Zend Framework 2 module that provides an improved get_browser function. This module could be standalone if "browscap" configuration setting in php.ini is undefined or does not point to the correct location of the browscap.ini file., (*4)

Contributing

If you wish to contribute to ZF2 Browscap, please read both the CONTRIBUTING.md file., (*5)

Requirements

Installation

Main Setup

By cloning project

  1. Install browscap by cloning it into ./vendor/.
  2. Clone this project into your ./vendor/ directory.

With composer

  1. Add this project in your composer.json:, (*6)

    "require": {
        "neilime/zf2-browscap": "dev-master"
    }
    
  2. Now tell composer to download ZF2 Browscap by running the command:, (*7)

    $ php composer.phar update
    

Post installation

  1. Enabling it in your application.config.phpfile., (*8)

    <?php
    return array(
        'modules' => array(
            // ...
            'Neilime\Browscap',
        ),
        // ...
    );
    

Configuration

  • string browscap_ini_path : (optionnal) only needed if the native php function get_browser is unavailable or if allows_native_get_browser option is set to false. Define the browscap.ini file path (allows locale or remote file)
  • Zend\Cache\Storage\StorageInterface|string|array cache: (optionnal) Define the cache storage adapter to store parsed browscap.ini.
    Allows classname and service retrieving an Zend\Cache\Storage\StorageInterface, or an array to be use with Zend\Cache\StorageFactory::factory. This not only saves you from loading and parsing the "browscap.ini" each time, but also guarantees an optimized loading procedure.
  • boolean allows_native_get_browser: Define if the native php function get_browser could be used if it's available.

How to use ZF2 Browscap

ZF2 Browscap module provides a service, helper for views and plugin for controllers, (*9)

  1. Call Browscap with the service manager, (*10)


    /* @var $serviceManager \Zend\ServiceManager\ServiceLocatorInterface */ $browscap = $serviceManager->get('BrowscapService'); //Retrieve "\Neilime\Browscap\BrowscapService" object var_dump($browscap->getBrowser()); //Display an object which will contain various data elements representing, for instance, the browser's major and minor version numbers and ID string;
  2. Call Browscap in a controller "get_browser" plugin expects the same params as the native php function get_browser., (*11)

    $browscap = $this->get_browser(); //Retrieve an object
    echo $browscap->parent;
    
    $browscap = $this->get_browser(null,true); //Retrieve an array
    echo $browscap['parent'];
    
    $browscap = $this->get_browser(
        \Zend\Http\Header\UserAgent::fromString('User-Agent: Mozilla/5.0 (Linux; Android 4.0.4; Desire HD Build/IMM76D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19')
    ); //Retrieve an object with an arbitrary user agent
    echo $browscap->parent;     
    
  3. Call Browscap in a view "get_browser" helper expects the same params as the native php function get_browser., (*12)

    $browscap = $this->get_browser(); //Retrieve an object
    echo $browscap->parent;
    
    $browscap = $this->get_browser(null,true); //Retrieve an array
    echo $browscap['parent'];
    
    $browscap = $this->get_browser(
        \Zend\Http\Header\UserAgent::fromString('User-Agent: Mozilla/5.0 (Linux; Android 4.0.4; Desire HD Build/IMM76D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19')
    ); //Retrieve an object with an arbitrary user agent
    echo $browscap->parent;
    

Tools

ZF2 Browscap provides console tools., (*13)

Features

Load & parse "browscap.ini" file (or update cached browscap.ini)

Usage

Load & parse "browscap.ini" file

php public/index.php load-browscap

The Versions

17/09 2013

dev-master

9999999-dev https://github.com/neilime/zf2-browscap

ZF2 Browscap is a Zend Framework 2 module that provides an improved 'get_browser' function. This module could be standalone if 'browscap' configuration setting in php.ini is undefined or does not point to the correct location of the browscap.ini file

  Sources   Download

MIT

The Requires

 

zend framework 2 standalone browscap get_browser browser capabilities

21/08 2013

1.1

1.1.0.0 https://github.com/neilime/zf2-browscap

ZF2 Browscap is a Zend Framework 2 module that provides an improved 'get_browser' function. This module could be standalone if 'browscap' configuration setting in php.ini is undefined or does not point to the correct location of the browscap.ini file

  Sources   Download

MIT

The Requires

 

zend framework 2 standalone browscap get_browser browser capabilities

05/07 2013

1.0

1.0.0.0 https://github.com/neilime/zf2-browscap

ZF2 Browscap is a Zend Framework 2 module that provides an improved 'get_browser' function. This module could be standalone if 'browscap' configuration setting in php.ini is undefined or does not point to the correct location of the browscap.ini file

  Sources   Download

MIT

The Requires

 

zend framework 2 standalone browscap get_browser browser capabilities