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_Browscap utilizes PHP's native
get_browser()in conjunction with browscap. While the database featureset is not as fine-grained as other projects, for the majority of purposes, it provides reliable, fast results.
Zend_Http_UserAgent_Features_Adapter_DeviceAtlas consumes the DeviceAtlas API, which is a paid, Enterprise-grade mobile device capabilities database.