PHPackages                             handsetdetection/php-apikit - 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. handsetdetection/php-apikit

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

handsetdetection/php-apikit
===========================

A library for stand alone or web service device detection, using HandsetDetection.com.

4.1.13(8y ago)38.5k↑1400%6[2 issues](https://github.com/HandsetDetection/php-apikit/issues)3MITPHPPHP &gt;=5.2.4

Since Aug 26Pushed 8y ago3 watchersCompare

[ Source](https://github.com/HandsetDetection/php-apikit)[ Packagist](https://packagist.org/packages/handsetdetection/php-apikit)[ Docs](https://github.com/HandsetDetection/php-apikit)[ RSS](/packages/handsetdetection-php-apikit/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (23)Used By (3)

[![Build Status](https://camo.githubusercontent.com/d8b4904efc308fdc3ef3f3bff029aa7039eb6b4e7fd78d69fbfc0bb3faf469dd/68747470733a2f2f7472617669732d63692e6f72672f48616e64736574446574656374696f6e2f7068702d6170696b69742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/HandsetDetection/php-apikit)[![Latest Stable Version](https://camo.githubusercontent.com/2d0fcf1b2e0f85a2c7c52d4cf83a88620575a0eea9c4ef356f35dc759dd91897/68747470733a2f2f706f7365722e707567782e6f72672f68616e64736574646574656374696f6e2f7068702d6170696b69742f762f737461626c65)](https://packagist.org/packages/handsetdetection/php-apikit)[![License](https://camo.githubusercontent.com/dd5fee5a9949863504fc77b62a8a652f43fb5432eb7b4019a05fe764d77301ba/68747470733a2f2f706f7365722e707567782e6f72672f68616e64736574646574656374696f6e2f7068702d6170696b69742f6c6963656e7365)](https://packagist.org/packages/handsetdetection/php-apikit)

PHP API Kit v4.0, implementing v4.0 of the HandsetDetection API.
================================================================

[](#php-api-kit-v40-implementing-v40-of-the-handsetdetection-api)

API Kits can use our web service or resolve detections locally depending on your configuration.

Installation
------------

[](#installation)

Download the package directly from github or use composer.

```
{
	"require": {
	  "handsetdetection/php-apikit": "4.*"
	}
}

```

Configuration
-------------

[](#configuration)

API Kit configuration files can be downloaded directly from Handset Detection.

1. Login to your dashboard
2. Click 'Add a Site'
3. Configure your new site
4. Grab the config file variables for your API Kit (from the site settings)
5. Place the variables into the hdconfig.php file

Examples
--------

[](#examples)

### Instantiate the HD4 object

[](#instantiate-the-hd4-object)

```
// Using the default config file
require_once('HD4.php');
$hd = new HandsetDetection\HD4();

```

OR

```
// Using a custom config file
require_once('HD4.php');
$hd = new HandsetDetection\HD4('/tmp/myCustomConfigFile.php');

```

### List all vendors

[](#list-all-vendors)

```
if ($hd->deviceVendors()) {
    $data = $hd->getReply();
    print_r($data);
} else {
    print $hd->getError();
}

```

### List all device models for a vendor (Nokia)

[](#list-all-device-models-for-a-vendor-nokia)

```
if ($hd->deviceModels('Nokia')) {
    $data = $hd->getReply();
    print_r($data);
} else {
    print $hd->getError();
}

```

### View information for a specific device (Nokia N95)

[](#view-information-for-a-specific-device-nokia-n95)

```
if ($hd->deviceView('Nokia','N95')) {
    $data = $hd->getReply();
    print_r($data);
} else {
    print $hd->getError();
}

```

### What devices have this attribute ?

[](#what-devices-have-this-attribute-)

```
if ($hd->deviceWhatHas('network','CDMA')) {
    $data = $hd->getReply();
    print_r($data);
} else {
    print $hd->getError();
}

```

### Basic device detection

[](#basic-device-detection)

This is the most simple detection call - http headers are picked up automatically.

```
if ($hd->deviceDetect()) {
    $tmp = $hd->getReply();
    print_r($tmp);
} else {
    print $hd->getError();
}

```

### Manually set the http headers (user-agent etc..)

[](#manually-set-the-http-headers-user-agent-etc)

```
$hd->setDetectVar('user-agent','Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95-3/20.2.011 Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413');
$hd->setDetectVar('x-wap-profile','http://nds1.nds.nokia.com/uaprof/NN95-1r100.xml');
if ($hd->deviceDetect()) {
    $tmp = $hd->getReply();
    print_r($tmp);
} else {
    print $hd->getError();
}

```

### Download the Full Ultimate Edition

[](#download-the-full-ultimate-edition)

Note : Increase the default timeout before downloading the archive.

```
$hd->setTimeout(500);
if ($hd->deviceFetchArchive()) {
    $data = $hd->getRawReply();
    echo "Downloaded ".strlen($data)." bytes";
} else {
    print $hd->getError();
    print $hd->getRawReply();
}

```

### Download the Community Ultimate Edition

[](#download-the-community-ultimate-edition)

```
$hd->setTimeout(500);
if ($hd->communityFetchArchive()) {
    $data = $hd->getRawReply();
    echo "Downloaded ".strlen($data)." bytes";
} else {
    print $hd->getError();
    print $hd->getRawReply();
}

```

Flexible Caching Options
------------------------

[](#flexible-caching-options)

Version 4.1.\* includes APC(u), Memcache, Memcached and Redis caching options. For backwards compatibility if no option is set in the config file then it defaults to APC.

Note : **Memcached** and **Memcached** both have a default maximum object size of 1Mb which is too low. We recommend increasing this limit to at least 5Mb with the -I or --max-item-size= options.

### Using Memcache

[](#using-memcache)

Include a the following cache configuration in your config file. Options represent any cache flags you would like to pass to the memcache::set call. See  for more information.

```
$hdconfig['cache'] = array (
	'memcache' => array (
		'options' => 0,
		'servers' => array(
			'localhost' => '11211'
		)
	)
)

```

### Using Memcached

[](#using-memcached)

Include a the following cache configuration in your config file. Options represent cache settings set via the setOption call : See  for more information. Pass options as $option =&gt; $value in the options array.

```
$hdconfig['cache'] = array (
	'memcached' => array(
		'options' => array(),
		'servers' => array(
			array('localhost', '11211'),
		)
	)
);

```

If you're using cache connection pooling then pass the pool name as follows :

```
$hdconfig['cache'] = array (
	'memcached' => array(
		'pool' => 'mypool',
		'options' => array(),
		'servers' => array(
			array('localhost', '11211'),
		)
	)
);

```

### Using Predis

[](#using-predis)

From version 4.1.11 we also have Redis as a caching option. Redis caching uses Predis, which you should include via composer. Use a caching config as follows:

```
$hdconfig['cache'] = array (
	'redis' => array (
		'scheme' => 'tcp',
		'host'   => '127.0.0.1',
		'port'   => 6379
	)
);

```

### Using PHPRedis

[](#using-phpredis)

From version 4.1.12 we also have PhpRedis as a caching option, which uses the redis.so extension from  . connect\_method can be connect or pconnect. pconnect connections also support a peristent\_id.

Use a caching config as follows:

```
$hdconfig['cache'] = array (
	'phpredis' => array (
		'connect_method' => 'pconnect',
		'host'   => '127.0.0.1',
		'port'   => 6379,
		'timeout' => 2.5,
		'persistent_id' => 'x'
	)
);

```

Extra Examples
--------------

[](#extra-examples)

Additional examples can be found in the examples.php file.

Getting Started with the Free usage tier and Community Edition
--------------------------------------------------------------

[](#getting-started-with-the-free-usage-tier-and-community-edition)

After signing up with our service you'll be on a free usage tier which entitles you to 20,000 Cloud detections (web service) per month, and access to our Community Edition for Ultimate (stand alone) detection. The archive for stand alone detection can be downloaded manually however its easiest to configure the API kit with your credentials and let the API kit do the heavy lifting for you. See examples above for how to do this.

Instructions for manually installing the archive are available at [v4 API Ultimate Community Edition, Getting Started](https://handsetdetection.readme.io/docs/getting-started-with-ultimate-community-full-editions)

Unit testing
------------

[](#unit-testing)

Unit tests use phpUnit and can be found in the tests directory.

API Documentation
-----------------

[](#api-documentation)

See the [v4 API Documentation](https://handsetdetection.readme.io).

API Kits
--------

[](#api-kits)

See the [Handset Detection GitHub Repo](https://github.com/HandsetDetection).

Support
-------

[](#support)

Let us know if you have any hassles ().

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 70.8% 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 ~59 days

Recently: every ~68 days

Total

20

Last Release

3162d ago

Major Versions

3.2.0 → 4.0.x-dev2015-09-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/92d21049bbe13c6cca11b3eb9b5e6e409c5c09d07a6a585c6f615f876686f19e?d=identicon)[elricho](/maintainers/elricho)

---

Top Contributors

[![elricho](https://avatars.githubusercontent.com/u/389028?v=4)](https://github.com/elricho "elricho (63 commits)")[![jessielabadan07](https://avatars.githubusercontent.com/u/5086137?v=4)](https://github.com/jessielabadan07 "jessielabadan07 (25 commits)")[![ThaDafinser](https://avatars.githubusercontent.com/u/533017?v=4)](https://github.com/ThaDafinser "ThaDafinser (1 commits)")

---

Tags

user agentdevicedetection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/handsetdetection-php-apikit/health.svg)

```
[![Health](https://phpackages.com/badges/handsetdetection-php-apikit/health.svg)](https://phpackages.com/packages/handsetdetection-php-apikit)
```

###  Alternatives

[jenssegers/agent

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

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

A PHP Class to detect a user's Browser. This encapsulation provides a breakdown of the browser and the version of the browser using the browser's user-agent string. This is not a guaranteed solution but provides an overall accurate way to detect what browser a user is using.

5876.7M19](/packages/cbschuld-browserphp)[hisorange/browser-detect

Browser &amp; Mobile detection package for Laravel.

1.1k10.1M50](/packages/hisorange-browser-detect)[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)[patrickschur/language-detection

A language detection library for PHP. Detects the language from a given text string.

8513.2M18](/packages/patrickschur-language-detection)[thadafinser/user-agent-parser

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

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

PHPackages © 2026

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