Caution: The documentation you are viewing is
for an older version of Zend Framework.
You can find the documentation of the current version at docs.zendframework.com
The Browscap UserAgent Features Adapter - Zend_Http
» Browscap is an open project dedicated to collecting an disseminating a "database" of browser capabilities -- actually a set of different files describing browser capablities. PHP has built-in support for using these files via the » get_browser() function. This function requires that your php.ini provides a browscap entry pointing to the PHP-specific php_browscap.ini file, which » you can download from the browscap site.
This class provides a features adapter that calls get_browser() in order to discover mobile device capabilities to inject into UserAgent device instances.
Note: You may need to restart your webserver
The browscap php.ini setting is a PHP_INI_SYSTEM setting, meaning it can only be set in your php.ini file or in your web server configuration. As such, you may need to restart your web server after adding the entry.
First, if you haven't already, » download the php_browscap.ini file, and put it somewhere your web server can access it; make sure the web server has permissions to read the file. Typically, you'll place this in the same location as your php.ini file.
Next, update your php.ini file to add the following line:
Note: Keep it simple
If you put your php_browscap.ini file next to the php.ini file, you can omit the path information, and simply specify the filename.
Next, simply provide configuration to your application as follows:
At this point, you're all set. You can access the browser information in a variety of ways. From within the MVC portion of your application, you can access it via the bootstrap. Within plugins, this is done by grabbing the bootstrap from the front controller.
From your action controller, use getInvokeArg() to grab the bootstrap, and from there, the user agent object.
Within your view, you can grab it using the UserAgent view helper.
Once you have the user agent object, you can query it for different capabilities. As one example, you may want to use an alternate layout script based on the user agent capabilities.
The browscap adapter has no configuration options.
Decompose the request in order to return an array of device capabilities.