PHPackages                             dmolsen/detector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dmolsen/detector

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dmolsen/detector
================

Combined browser- &amp; feature-detection for your app

v085.x-dev(10y ago)022MITPHP

Since Sep 16Pushed 10y ago1 watchersCompare

[ Source](https://github.com/hamway/Detector)[ Packagist](https://packagist.org/packages/dmolsen/detector)[ Docs](http://detector.dmolsen.com/)[ RSS](/packages/dmolsen-detector/feed)WikiDiscussions v085 Synced 1mo ago

READMEChangelogDependencies (1)Versions (1)Used By (0)

Detector v0.8.5
===============

[](#detector-v085)

Detector is a simple, PHP- and JavaScript-based browser- and feature-detection library that can adapt to new devices &amp; 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](http://modernizr.com/) it records the HTML5 &amp; CSS3 features a requesting browser may or may not support. [ua-parser-php](https://github.com/tobie/ua-parser/tree/master/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.

The server-side portion of Detector is based upon [modernizr-server](https://github.com/jamesgpearce/modernizr-server) by James Pearce ([@jamespearce](http://twitter.com/#!/jamespearce)) and the browser-detection library [ua-parser-php](https://github.com/tobie/ua-parser/tree/master/php). Detector utilizes [Modernizr](http://www.modernizr.com/) for its client-side, feature-detection support.

Demo of Detector
----------------

[](#demo-of-detector)

A very [simple demo of Detector](http://detector.dmolsen.com/) is available for testing. It's also now in production on the [West Virginia University home page](http://www.wvu.edu/).

Features
--------

[](#features)

The following features are as of v0.8.5 of Detector:

- stores features detected with [Modernizr 2.5.2](http://www.modernizr.com/) ([list](http://detector.dmolsen.com/demo/modernizr-listing/)) and browser &amp; device information detected with [ua-parser-php](https://github.com/tobie/ua-parser/tree/master/php) (based on [ua-parser](http://code.google.com/p/ua-parser/)) on the server as part of a browser profile for easy retrieval
- uses the user agent string as a unique key for looking up information (e.g. one profile per user agent)
- majority of tests are run only once per unique user agent string so only one user is ever tested &amp; redirected
- [add your own feature tests](https://github.com/dmolsen/Detector/wiki/Detector-Test-Tutorial) and store the results using Modernizr's addTest() API
- tests can be created that run once per user agent, once per session, or on every request
- version your browser profiles so you can force them to be recreated after adding new tests
- [easily organize browsers into families](https://github.com/dmolsen/Detector/wiki/Detector-Family-Tutorial) based on a mix of supported features &amp; device information
- browser &amp; bots that don't use JavaScript or cookies can still use your site using a default browser profile
- provide default families for search engines and browsers that don't support javascript or cookies so your best side is always showing
- give your mobile users a "desktop" view via family switching (assuming you use a templating system)
- push feature information to the browser via CSS classes and/or a JavaScript object a la Modernizr
- use with a templating system like Mustache to [create a RESS system](https://github.com/dmolsen/Detector/wiki/Templating-with-Detector-&-Mustache-Tutorial)

Tutorials
---------

[](#tutorials)

- [Adding &amp; Using Detector With Your Application](https://github.com/dmolsen/Detector/wiki/Adding-&-Using-Detector-With-Your-Application)
- [Creating Browser Groupings](https://github.com/dmolsen/Detector/wiki/Detector-Family-Tutorial)
- [Creating Feature Tests for Detector](https://github.com/dmolsen/Detector/wiki/Detector-Test-Tutorial)
- [Pushing Detector Data to the Browser](https://github.com/dmolsen/Detector/wiki/Pushing-Detector-Data-to-the-Browser-Tutorial)
- [Templating with Detector &amp; Mustache](https://github.com/dmolsen/Detector/wiki/Templating-with-Detector-&-Mustache-Tutorial)

More Information
----------------

[](#more-information)

- [How Detector Works](https://github.com/dmolsen/Detector/wiki/How-Detector-Works)
- [RESS, Server-Side Feature-Detection and the Evolution of Responsive Web Design](http://www.dmolsen.com/mobile-in-higher-ed/2012/02/21/ress-and-the-evolution-of-responsive-web-design/)
- [Why I Created Detector](http://www.dmolsen.com/mobile-in-higher-ed/2012/01/18/introducing-detector-combining-browser-feature-detection-for-your-web-app/)

Credits
-------

[](#credits)

First and foremost, thanks to James Pearce ([@jamespearce](http://twitter.com/jamespearce)) for putting together [modernizr-server](https://github.com/jamesgpearce/modernizr-server) and giving me a great base to work from. I also took some of the copy from his README and used it in the section, "Adding Detector to Your Application." Also, thanks to the guys behind [Modernizr](http://www.modernizr.com/) for giving developers a great lib as well as the the ability to expand Modernizr via `Modernizr.addTest()`. Finally, thanks to Bryan Rieger ([@bryanrieger](http://twitter.com/bryanrieger)) &amp; Stephanie Rieger ([@stephanierieger](http://twitter.com/stephanierieger)) of Yiibu and Luke Wroblewski ([@lukew](http://twitter.com/lukew)) for providing inspiration via [Profile](https://github.com/yiibu/profile) and [RESS](http://www.lukew.com/ff/entry.asp?1392) respectively.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3898d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/efd32c0de61ee93d67afc995529d5aa27e17cc41b89b33a466a11e46dcafa4d0?d=identicon)[hamway](/maintainers/hamway)

---

Top Contributors

[![dmolsen](https://avatars.githubusercontent.com/u/2746?v=4)](https://github.com/dmolsen "dmolsen (336 commits)")[![hamway](https://avatars.githubusercontent.com/u/390578?v=4)](https://github.com/hamway "hamway (3 commits)")

---

Tags

detectoruseragentuser agentdevicefeature detectionua-parser-phpYABFDL

### Embed Badge

![Health badge](/badges/dmolsen-detector/health.svg)

```
[![Health](https://phpackages.com/badges/dmolsen-detector/health.svg)](https://phpackages.com/packages/dmolsen-detector)
```

###  Alternatives

[jenssegers/agent

Desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

4.8k67.8M440](/packages/jenssegers-agent)[foroco/php-browser-detection

Ultra fast PHP library to detect browser, OS, platform and device type by User-Agent parsing

1554.7M7](/packages/foroco-php-browser-detection)[woothee/woothee

Cross-language UserAgent classifier library, PHP implementation

108633.5k4](/packages/woothee-woothee)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
