Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



17 Commits

Repository files navigation

Mobile Detect

Motto: "Every business should have a mobile detection script to detect mobile readers."

MobileDetect is a CFC port of the Mobile_Detect PHP Library which was originally authored by Victor Stanciu and is now currently authored by Serban Ghita and Nick Ilyin

Their project is on GitHub and can be seen here:

The site for their project is:

I've used this library in various PHP projects and decided to port it over to be able to use in my ColdFusion Projects.

The library is used for detecting mobile devices (including tablets). It uses the UserAgent string combined with specific HTTP headers to detect the mobile environment.

This current version is based on their 2.8.22 release

###Supported Versions This CFC is script based and written using some of the new language enhancements in ColdFusion 11. Although making it compatible with earlier versions can be done by replacing the code using the Member Functions for their previous equivalent global functions.

###Differences from PHP Library The one main difference is the "is" function. As it is a reserved word in ColdFusion I had to chage it to "_is". Below are some examples of how to use.

MobileDetect = new MobileDetect();

// Basic Detection

// Magic Methods
// [...]

// Alternative to magic methods.

// Additional match method.

// Browser grade method.

// Overwrite UserAgent or HttpHeaders to use
MobileDetect.setUserAgent(userAgent); // string
MobileDetect.setHttpHeaders(httpHeaders); // struct

This should help you familiarize with how the CFC works. You can compare the examples above to their Wiki Page and get even more examples on how to use.

You can also run the examples included by executing in your local ColdFusion install or simply use CommandBox to run and execute.

After installing CommandBox, browse to the directory of this repo and type the following and then browse to the examples folder:

box server start

Examples are also available here