The Browscap UserAgent Features AdapterOverview» 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.
Quick StartFirst, 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:
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.
Configuration OptionsThe browscap adapter has no configuration options. Available Methods
|
|