With the plethora of mobile devices available on the market, it's increasingly important to be able to identify the capabilities of those devices in order to present content in a an appropriate way. For instance, if the device is not capable of displaying images, you might want to omit them from the markup; alternately, if a device is capable of Flash, you may want to provide a Flash-based user interface.
The process of identifying a device's capabilities typically first requires knowing the
HTTP User Agent, and then comparing that user agent against a database of user agent
Zend_Http_UserAgent was created to provide these
capabilities for your applications. It consists of several major features:
Zend_Http_UserAgentclass, which detects the User Agent, and gives you a device object, as well as persists the device object for later retrieval.
A Zend_Http_UserAgent_Device interface, and a number of implementations that implement it. These objects utilize a features adatper to discover device capabilities, and then allow you to introspect those capabilities.
A Zend_Http_UserAgent_Features_Adapter interface; concrete implementations provide the ability to discover device capabilities, or features.
A Zend_Http_UserAgent_Storage interface, which is used to persist discovered devices for given users, allowing for faster device capability discovery on subsequent page visits.
A view helper that can be used within your view scripts and layouts to branch display logic based on device capabilities.
Zend_Applicationresource for configuring and instantiating the user agent object, as well as seeding the view helper with the user agent object instance.
At the time of this writing, The
UserAgent component provides
Zend_Http_UserAgent_Features_Adapter_Wurfl consumes the WURFL (Wireless Universal Resource File) PHP API. This database is considered one of the most comprehensive mobile device capabilities databases available.
Zend_Http_UserAgent_Features_Adapter_TeraWurfl consumes the TeraWurfl API, which is built on top of WURFL, and aimed at providing a highly available, highly performant lookup mechanism.
Zend_Http_UserAgent_Features_Adapter_DeviceAtlas consumes the DeviceAtlas API, which is a paid, Enterprise-grade mobile device capabilities database.