PHPackages                             mimmi20/wurfl - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. mimmi20/wurfl

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

mimmi20/wurfl
=============

the Wurfl PHP Library for PHP 5.3+

1.7.1.1(10y ago)1294.3k↓37.3%32AGPLv3PHPPHP &gt;=5.3.3

Since Dec 2Pushed 9y ago5 watchersCompare

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

READMEChangelog (10)Dependencies (10)Versions (17)Used By (2)

Wurfl
=====

[](#wurfl)

an clone of the official Wurfl PHP library updated for PHP 5.3

[![Build Status](https://camo.githubusercontent.com/1c11e691b9ba8f707b24f5f596dbf266e1ddb5192c22ac90550e768fec8a7845/68747470733a2f2f6170692e7472617669732d63692e6f72672f6d696d6d6932302f577572666c2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/mimmi20/Wurfl)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/926e03e17aeda954c29b0997c084aaeaa4a69ce971a8aa9097c53f3d61efb640/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696d6d6932302f577572666c2f6261646765732f7175616c6974792d73636f72652e706e673f733d35653838653139643361363539663734636134363831373064373063333063393463346162326330)](https://scrutinizer-ci.com/g/mimmi20/Wurfl/)[![Code Coverage](https://camo.githubusercontent.com/e5f8dac1c34dad45c10a10d51d913fe78489f95c2670b6098bf9e0de81929dc1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696d6d6932302f577572666c2f6261646765732f636f7665726167652e706e673f733d62396136363164363131653633633531336333643638303035373263336630366535323062616534)](https://scrutinizer-ci.com/g/mimmi20/Wurfl/)

Submitting bugs and feature requests
------------------------------------

[](#submitting-bugs-and-feature-requests)

Bugs and feature request are tracked on [GitHub](https://github.com/mimmi20/Wurfl/issues)

Important changes
-----------------

[](#important-changes)

These changes are made:

- added Wurfl namespace, removed the part "WURFL" from the filenames
- merged the \\Wurfl\\Service and \\Wurfl\\ManagerFactory into \\Wurl\\Manager
- Parts of the original Wurfl Package were extracted to their own repositories, these are installed via composer
- the Xml Configuration class is replaced with FileConfig class, who is also able to read config files in ini/yaml format

the official WURFL PHP API
==========================

[](#the-official-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

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 may be 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.

```
/**
 * This makes our life easier when dealing with paths. Everything is relative
 * to the application root now.
 *
 * change this to pass to your project settings
 */
chdir(dirname(__DIR__));
require 'vendor/autoload.php';

/*
 * relative to the root dir
 * -> $resourcesDir = /resources
 */
$resourcesDir   = 'resources';
$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
 *
 * It is recommended to use the defined class constants instead of their
 * string values:
 *
 * \Wurfl\Configuration\Config::MATCH_MODE_PERFORMANCE
 * \Wurfl\Configuration\Config::MATCH_MODE_ACCURACY
 */
$wurflConfig->matchMode(\Wurfl\Configuration\Config::MATCH_MODE_PERFORMANCE);

// Setup WURFL Persistence
$wurflConfig->persistence(
    'file',
    array(\Wurfl\Configuration\Config::DIR => $persistenceDir)
);

// Setup Caching
$wurflConfig->cache(
    'file',
    array(
        \Wurfl\Configuration\Config::DIR        => $cacheDir,
        \Wurfl\Configuration\Config::EXPIRATION => 36000
    )
);

// Create the cache instance from the configuration
$cacheStorage = Storage\Factory::create($wurflConfig->cache);

// Create the persistent cache instance from the configuration
$persistenceStorage = Storage\Factory::create($wurflConfig->persistence);

// Create a WURFL Manager from the WURFL Configuration
$wurflManager = new \Wurfl\Manager($wurflConfig, $persistenceStorage, $cacheStorage);
```

If you dont want to build these three objects by yourself, you may use the factory method.

```
$wurflManager = \Wurfl\Manager::factory($wurflConfig);
```

Now you can use some of the `\Wurfl\Manager` 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 )
    - Memory
    - File

    Additional to the official providers the following connectors are added:

    - Zend Cache
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)

    Additional to the official providers the following connectors are added:

    - Zend Cache

### 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
 *
 * It is recommended to use the defined class constants instead of their
 * string values:
 *
 * \Wurfl\Configuration\Config::MATCH_MODE_PERFORMANCE
 * \Wurfl\Configuration\Config::MATCH_MODE_ACCURACY
 */
$wurflConfig->matchMode(\Wurfl\Configuration\Config::MATCH_MODE_PERFORMANCE);

// Setup WURFL Persistence
$wurflConfig->persistence(
    'file',
    array(\Wurfl\Configuration\Config::DIR => $persistenceDir)
);

// Setup Caching
$wurflConfig->cache(
    'file',
    array(
        \Wurfl\Configuration\Config::DIR        => $cacheDir,
        \Wurfl\Configuration\Config::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 the \\Wurfl\\Request\\GenericRequest object for you
3. `getDeviceForUserAgent(string $userAgent)`Used to query the API for a given User Agent 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\CustomDeviceInterface */
$device = $wurflManager->getDeviceForHttpRequest($_SERVER);

/* @var $root \Wurfl\Device\ModelDeviceInterface */
$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

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 99.7% 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 ~62 days

Recently: every ~12 days

Total

15

Last Release

3677d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5fea77dd303122241a6caac15ea7456607bcb6f5db869fc8fc9eaf3ec0630a84?d=identicon)[mimmi20](/maintainers/mimmi20)

---

Top Contributors

[![mimmi20](https://avatars.githubusercontent.com/u/1120192?v=4)](https://github.com/mimmi20 "mimmi20 (749 commits)")[![peterhough](https://avatars.githubusercontent.com/u/88101?v=4)](https://github.com/peterhough "peterhough (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

httpbrowserparseruser agentWurfl

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k314.0M3.4k](/packages/symfony-http-client)[mimmi20/browser-detector

Library to detect Browsers and Devices

48153.5k3](/packages/mimmi20-browser-detector)[riverline/multipart-parser

One class library to parse multipart content with encoding and charset support.

17057.4M55](/packages/riverline-multipart-parser)[thadafinser/user-agent-parser

UserAgent parsing done right http://useragent.mkf.solutions/

249316.9k2](/packages/thadafinser-user-agent-parser)[aplus/http

Aplus Framework HTTP Library

2311.6M10](/packages/aplus-http)[duzun/hquery

An extremely fast web scraper that parses megabytes of HTML in a blink of an eye. No dependencies. PHP5+

363146.3k4](/packages/duzun-hquery)

PHPackages © 2026

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