Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPMaster.com:
Server-Side Device Detection with Browscap
Jul 25, 2013 @ 18:09:12

In a new tutorial posted to PHPMaster.com today, Lukas White talks about using the Browscap functionality to do server-side device/client detection in your applications.

An alternative solution to the problem is to use server-side device detection and then take certain actions based on that information. One possibility is to simply forward requests for a mobile site to a different URL. Another possibility is to adapt the layout – or indeed content – programmatically as it’s generated on the server. Taking a server-side approach is the basis of this article, which looks in detail at the Browser Capabilities Project, or Browscap for short, to provide the information on which to base these decisions.

He starts with some of the basics - User-Agent strings that most devices will send to your site and their structure. He then talks about the Browscap project and the PHP support for its use. He shows how to get it all installed via Composer and how to use the "browscap-php" library to get the current browser information. He includes an example of the output and shows how to use this to redirect the user to a mobile site if needed. He also adds in a bit at the end about using it for layout switching or for showing the user the correct download links based on their client.

tagged: serverside useragent browscap tutorial detection

Link: http://phpmaster.com/server-side-device-detection-with-browscap

Henry Hayes' Blog:
Zend Framework UserAgent Browscap Implementation
Jun 20, 2012 @ 15:55:32

Henry Hayes has a recent post to his blog looking at a the change for the user agent support for the browser detection functionality in the Zend Framework.

Recently it has come to light that Zend Framework are dropping support for the WurflApi Features Adapter in the Zend_Http_UserAgent component. This is due to licensing issues. As of version 1.12 Zend_Http_UserAgent_Mobile constant DEFAULT_FEATURES_ADAPTER_CLASSNAME now specifies that Zend_Http_UserAgent_Features_Adapter_Browscap is now the default mobile adapter.

He shows you how to get the browscap support set up and configured for your PHP installation and what needs to be done to a pre-1.12 ZF release application (using this library) and in a post-1.12 application (almost nothing).

tagged: zendframework browscap browser detection mobile update

Link:


Trending Topics: