Detector v0.5 Released: ua-parser-php Integration, Browser Families, Expanded Feature Tests, & New Wiki

Feb. 27, 2012: A small update, v0.5.1, was made to Detector to clean up PHP Notices as well as add two methods to push Detector data to the browser so the data can be used a la Modernizr.

Detector v0.5 has been posted to GitHub. The Detector demo site has also been updated to reflect the new version.

About Detector

Detector is a simple, PHP- and JavaScript-based browser- and feature-detection library that can adapt to new devices & browsers on its own without the need to pull from a central database of browser information. Detector dynamically creates profiles using a browser's (mainly) unique user-agent string as a key. Using Modernizr it records the HTML5 & CSS3 features a requesting browser may or may not support. ua-parser-php is used to collect and record any useful information (like OS or device name) the user-agent string may contain.

With Detector a developer can serve the appropriate markup, stylesheets, and JavaScript to a requesting browser without being completely dependent on a front-end-only resource loader nor a browser-detection library being up-to-date. Detector can be used with a solution like Mustache to provide robust templating support.

The following are the major changes in this release:

ua-parser-php Integration

I was unhappy with the original browser detection library in Detector so I created a PHP-based pseudo-fork of the ua-parser project called ua-parser-php. It is included as a submodule of Detector and provides a much more robust classification system for browsers and mobile devices. Because of the number of attributes it parses out of a user-agent string it should give developers more flexibility when developing solutions.

Browser Families

With the new families feature in Detector developers can organize browsers that share certain traits into groupings. With families a developer can test for a browser's grouping rather than each individual feature that browser may support when displaying content. This might be especially useful for templating solutions.

Expanded Feature Tests

Modernizr 2.5.2 has been included with this release as well as an expanded set of features including tests for cssremunit, deviceorientation, devicemotion, and lowbandwidth support. See the full list of Detector's core tests.

Detector Wiki Added

I've attempted to grow the documentation for Detector beyond the original, limited README by using the wiki that comes with a GitHub repository. Content includes:

Other Changes

Those are the big changes but their are a few other, minor changes:

  • a configuration file for setting debug mode as well of locations of files & directories is now included
  • both core and extended profiles can now be versioned
  • the original layout of the files has been cleaned up some
  • two simple demos, one for including a YouTube video and the other for templating, are now included
  • while not a change in Detector per se, the archive of user agents now contains 170+ user agents and their associated feature tests

If you have any questions about the project please feel free to drop a line in the comments.

This article was posted