PHPackages                             mimmi20/modernizr-server - 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. mimmi20/modernizr-server

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

mimmi20/modernizr-server
========================

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

1.0.5(10y ago)01031MITJavaScriptPHP &gt;=5.6.0

Since Aug 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/mimmi20/modernizr-server)[ Packagist](https://packagist.org/packages/mimmi20/modernizr-server)[ Docs](https://github.com/mimmi20/modernizr-server/)[ RSS](/packages/mimmi20-modernizr-server/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (5)Dependencies (3)Versions (7)Used By (1)

modernizr-server
================

[](#modernizr-server)

[Modernizr](http://modernizr.com) is a great way to find out about your user's browser capabilities. However, you can only access its API on the browser itself, which means you can't easily benefit from knowing about browser capabilities in your server logic.

Progressive enhancement, media queries and body classes are fine for tweaking sites and their appearance. But for structural changes to sites and pages, sometimes it's much simpler to just emit the right markup from the server in the first place.

The modernizr-server library is a way to bring Modernizr browser data to your server scripting environment. For example, in PHP:

```

```

The server knows: canvas: 1 canvastext: 1 geolocation: 1 crosswindowmessaging: 1 websqldatabase: 1 indexeddb: 0 hashchange: 1 ...

Exactly the same feature detection is available through this (PHP) API on the server as is available through the (Javascript) API on the client.

Currently, there is only a PHP implementation of the server-side API, but other languages would be a breeze. Stay tuned to the project for more.

Also: this is a young project, so please use in high-traffic production environments with due caution :-)

How to use it (with PHP)
------------------------

[](#how-to-use-it-with-php)

Download the latest Modernizr script from  and place it in the `modernizr.js`directory. Within that directory, the file should also be called `modernizr.js`, but it can be either the compressed or uncompressed version of the file. (If you want to put it in a different place, see the note at the bottom of this section.)

Ideally, the `modernizr-server.php` library should be included at the very start of your PHP script - or at the very least before any HTML is emitted:

```
