PHPackages                             wurfl/wurfl-api - 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. [API Development](/categories/api)
4. /
5. wurfl/wurfl-api

ActiveLibrary[API Development](/categories/api)

wurfl/wurfl-api
===============

WURFL, the Wireless Universal Resource FiLe, is a Device Description Repository (DDR), i.e. a software component that maps HTTP Request headers to the profile of the HTTP client (Desktop, Mobile Device, Tablet, etc.) that issued the request

1.7.1.1(10y ago)11128.0k6[1 issues](https://github.com/sam-media/wurfl-api/issues)AGPLv3PHPPHP &gt;=5.3.0

Since Jan 9Pushed 10y ago2 watchersCompare

[ Source](https://github.com/sam-media/wurfl-api)[ Packagist](https://packagist.org/packages/wurfl/wurfl-api)[ RSS](/packages/wurfl-wurfl-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (9)Used By (0)

ScientiaMobile WURFL PHP API
============================

[](#scientiamobile-wurfl-php-api)

-
-

---

LICENSE
=======

[](#license)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Please refer to the COPYING file distributed with this package for the complete text of the applicable GNU Affero General Public License.

If you are not able to comply with the terms of the AGPL license, commercial licenses are available from ScientiaMobile, Inc at

PHP Supported Versions
======================

[](#php-supported-versions)

- PHP &gt;= 5.3.2

Getting Started
===============

[](#getting-started)

Download a release archive from wurfl site and extract it to a directory suitable for your application.

To start using the API you need to set some configuration options.

> **IMPORTANT**: The WURFL API is closely tied to the WURFL.XML file. New versions of the WURFL.XML are compatible with old versions of the API by nature, but the reverse is NOT true. Old versions of the WURFL.XML are NOT guarenteed to be compatible with new versions of the API. Let's restate that: This API is NOT compatible with old versions of the WURFL.XML. The oldest copy of WURFL that can be used with this API is included in this distribution.

### For the impatient ones

[](#for-the-impatient-ones)

Please look at the sample of the configuration files in examples/demo/ directory.

```
$wurflDir = dirname(__FILE__) . '/../../../WURFL';
$resourcesDir = dirname(__FILE__) . '/../../resources';

require_once $wurflDir.'/Application.php';

$persistenceDir = $resourcesDir.'/storage/persistence';
$cacheDir = $resourcesDir.'/storage/cache';

// Create WURFL Configuration
$wurflConfig = new WURFL_Configuration_InMemoryConfig();

// Set location of the WURFL File
$wurflConfig->wurflFile($resourcesDir.'/wurfl.zip');

// Set the match mode for the API ('performance' or 'accuracy')
$wurflConfig->matchMode('performance');

// Setup WURFL Persistence
$wurflConfig->persistence('file', array('dir' => $persistenceDir));

// Setup Caching
$wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000));

// Create a WURFL Manager Factory from the WURFL Configuration
$wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);

// Create a WURFL Manager
/* @var $wurflManager WURFL_WURFLManager */
$wurflManager = $wurflManagerFactory->create();
```

Now you can use some of the `WURFL_WURFLManager` class methods;

```
$device = $wurflManager->getDeviceForHttpRequest($_SERVER);
$device->getCapability("is_wireless_device");
$device->getVirtualCapability("is_smartphone");
```

Create a configuration object
-----------------------------

[](#create-a-configuration-object)

1. Set the paths to the location of the main WURFL file (you can use zip files if you have the zip extension enabled)
2. Configure the Persistence provider by specifying the provider and the extra parameters needed to initialize the provider. The API supports the following mechanisms:

    - Memcache ()
    - APC (Alternative PHP Cache )
    - MySQL
    - Memory
    - File
3. Configure the Cache provider by specifying the provider and the extra parameters needed to initialize the provider. The API supports the following caching mechanisms:

    - Memcache ()
    - APC (Alternative PHP Cache )
    - File
    - Null (no caching)

### Example Configuration

[](#example-configuration)

```
// Create WURFL Configuration
$wurflConfig = new WURFL_Configuration_InMemoryConfig();
// Set location of the WURFL File
$wurflConfig->wurflFile($resourcesDir.'/wurfl.zip');
// Set the match mode for the API ('performance' or 'accuracy')
$wurflConfig->matchMode('performance');
// Setup WURFL Persistence
$wurflConfig->persistence('file', array('dir' => $persistenceDir));
// Setup Caching
$wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000));
```

Using the WURFL PHP API
-----------------------

[](#using-the-wurfl-php-api)

### Getting the device

[](#getting-the-device)

You have four methods for retrieving a device:

1. `getDeviceForRequest(WURFL_Request_GenericRequest $request)`where a WURFL\_Request\_GenericRequest is an object which encapsulates userAgent, ua-profile, support for xhtml of the device.
2. `getDeviceForHttpRequest($_SERVER)`Most of the time you will use this method, and the API will create the WURFL\_Request\_GenericRequest object for you.
3. `getDeviceForUserAgent(string $userAgent)`Used to query the API for a given userAgent string.
4. `getDevice(string $deviceID)`Gets the device by its device ID (ex: `apple_iphone_ver1`).

Usage example:

```
$device = $wurflManager->getDeviceForHttpRequest($_SERVER);
```

### Getting the device properties and its capabilities

[](#getting-the-device-properties-and-its-capabilities)

The properties Device ID and Fall Back Device ID are properties of the device:

```
$deviceID = $device->id;
$fallBack = $device->fallBack;
```

To get the value of a capability, use `getCapability()`:

```
$value = $device->getCapability("is_tablet");
$allCaps = $device->getAllCapabilities();
```

To get the value of a virtual capability, use `getVirtualCapability()`:

```
$value = $device->getVirtualCapability("is_smartphone");
$allVCaps = $device->getAllVirtualCapabilities();
```

### Useful Methods

[](#useful-methods)

The root WURFL device object has some useful functions:

```
/* @var $device WURFL_CustomDevice */
$device = $wurflManager->getDeviceForHttpRequest($_SERVER);

/* @var $root WURFL_Xml_ModelDevice */
$root = $device->getRootDevice();

$group_names = $root->getGroupNames();
$cap_names = $root->getCapNames();
$defined = $root->isCapabilityDefined("foobar");
```

### WURFL Reloader

[](#wurfl-reloader)

WURFL can update the persistence data automatically without any configuration by checking the modification time of the WURFL file. To enable, set allow-reload to true in the config:

```
$wurflConfig->allowReload(true);
```

If you have any questions, please take a look at the documentation on , and/or the ScientiaMobile Support Forum at

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 91.3% 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

Every ~119 days

Recently: every ~72 days

Total

8

Last Release

3677d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4930410?v=4)[Sam Media](/maintainers/sam-media)[@sam-media](https://github.com/sam-media)

---

Top Contributors

[![mimmi20](https://avatars.githubusercontent.com/u/1120192?v=4)](https://github.com/mimmi20 "mimmi20 (73 commits)")[![slashmili](https://avatars.githubusercontent.com/u/585764?v=4)](https://github.com/slashmili "slashmili (7 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/wurfl-wurfl-api/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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