• About Us
  • Blog
  • Basket
  • Account
  • Sign In
  •  

Blog

Published on Tuesday, October 2, 2012

51Degrees.mobi device detection with the Zend Framework and Zend Server

In this short guide, I will show you how to implement the The 51Degrees.mobi PHP device detection API into a Zend framework project running on a Zend application server. Although this article has been written with Zend server in mind, the principals will apply to any other PHP compatible application server.

Note: When mentioning the "document root" of your web server, we are referring to the "wwwroot” folder usually found in C:/inetpub/wwwroot on a Windows machine.

1)    Download the 51Degrees.mobi PHP zip file.
You can find the latest zip file containing the PHP API here. There is also a general setup guide located here.

2)    Unzip the file into your document root.
As mentioned above, this is the “wwwroot” folder if you are using Zend Server.

3)    In your Zend project, add the following includes:
51Degrees\51Degrees.mobi.php
51Degrees\51Degrees.mobi.usage.php

This second line is optional, but it helps with the ongoing development of 51Degrees. Replace the first part of each line ("51Degrees\") with the path to your 51Degrees.mobi PHP folder

4)    Call the 51Degrees.mobi detection function.
Use the variable $_51d[“Property”] to obtain information about the connecting device. This can be used from anywhere within your Zend Framework application, provided you have included the 51Degrees.mobi PHP files. For example, to detect whether the device is mobile (possible with the free open source version of the API) you would use the following code:

<?php
    $IsMobile = $_51d == "True";
    if($IsMobile)
        // Behavior if device is mobile
    else if (!$IsMobile)
        // Behavior if device is not mobile
?>

5)    Modify to suit your needs.
To get the most from the 51Degrees.mobi API, check out the property dictionary here to see the full list of properties available to both the Lite and Premium versions of the software.
Comments (0)

Author: Products Team

Categories: Development

Tags: Device Detection , PHP

Jack
>

Products Team

Other posts by Products Team
Contact author

Name:
Email:
Subject:
Message:
x

Tags

.NET 4G 51Degrees 5G Acer Adform Adtech Advertising Afilias Alcatel Amazon AMP Analysis Analytics Android Apache API Apple Asian Market ASP.NET Asus Blackberry Browser C C# Centro Chrome Cloud CMS CPU CSS3 Data Data Blog Data File Daydream Design Detection Developers Device Device Data Device Detection Device Intelligence Device Models Device property DeviceAtlas Disney dmexco DotNetNuke Download ebay Ericsson Event Facebook Firefox Foundation Framework Galaxy git repositories Google Google Analytics Google Daydream GPU GSMA Guess HAProxy Hash Trie HTC HTML5 HTTP HTTP Headers Huawei Infinix Ingeniux Internet usage iOS iOS 13 ipad iPadOS iPhone iPhone 11 Java Javascript Kentico LG Liferay LTE m.dot Memory Memory leak Meta Data Microsoft Mobile Mobile Analysis Mobile Analytics Mobile Devices Mobile Marketing Mixer Motorola Mozilla MWC MWC 2017 MWC16 Native Apps NET New Release News Nexus NFC NGINX Nokia OnePlus 5 Opera Operating System Oppo Optimisation OS Patent Performance PHP Press Release Price Band programmatic Publishers Python Redirection Research Responsive Images Responsive web design RESS Review RTB RWD Safari Samsung Scala ScientiaMobile SEO Server Server-side optimisation Seznam.cz Sitecore Smart TV Smartphone Smartwatches Sony Swedish Beers Tablet Tencent Testing Tips Tutorial Umbraco Update User Agent User-Agent Valgrind Varnish Varnish Cache Video Vodafone VoLTE Web Web Apps Web content management Webtrekk White Paper Widgets WiFi Windows WURFL Xiaomi Xperia ZTE