PHPackages                             enygma/yubikey - 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. enygma/yubikey

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

enygma/yubikey
==============

PHP library to interface with the Yubikey REST API

3.9(1y ago)79778.7k—5.6%16[4 PRs](https://github.com/enygma/yubikey/pulls)8MITPHPPHP &gt;=7.4

Since Mar 16Pushed 1y ago5 watchersCompare

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

READMEChangelogDependencies (2)Versions (22)Used By (8)

Yubikey PHP Library
===================

[](#yubikey-php-library)

[![Travis-CI Build Status](https://camo.githubusercontent.com/8f66cea17097b6be37734d9756596ccb76f667b1cc376b48c4e589eb22485e14/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f656e79676d612f797562696b65792e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/enygma/yubikey)[![Codacy Badge](https://camo.githubusercontent.com/55eb63949fd61472754857b1e28cd3329f4a08e9e3c28a9b5fead7378d5dbfad/68747470733a2f2f7777772e636f646163792e636f6d2f70726f6a6563742f62616467652f3662373363353661323137333461366439336461653630313966373333633565)](https://www.codacy.com)[![Code Climate](https://camo.githubusercontent.com/e29dd2a0eb65164769b749c79011d545099ab3aebc1b788a933950cb78890cef/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f656e79676d612f797562696b65792f6261646765732f6770612e737667)](https://codeclimate.com/github/enygma/yubikey)[![Total Downloads](https://camo.githubusercontent.com/93e3f1d096b3f6690cab7cb57afc7d49d2016e614fd19a22461ae05b1819c1ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656e79676d612f797562696b65792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/enygma/yubikey)

This library lets you easily interface with the Yubico REST API for validating the codes created by the Yubikey.

### Requirements:

[](#requirements)

- An API as requested from the Yubico site
- A client ID requested from Yubico
- A Yubikey to test out the implementation

### Installation

[](#installation)

Use the followng command to install the library via Composer:

```
composer require enygma/yubikey

```

### Usage:

[](#usage)

Look at the `test.php` example script to see how to use it. This can be executed like:

`php test.php [generated key]`

Example code:

```

```

### HTTP vs HTTPS

[](#http-vs-https)

By default the library will try to use a `HTTPS` request to the host given. If you need to disable this for some reason (like no SSL support), you can use the `setUseSecure` method and set it to false:

```
$v = new \Yubikey\Validate($apiKey, $clientId);
$v->setUseSecure(false);
```

### Overriding hosts

[](#overriding-hosts)

The library comes with a set of hostnames for the Yubico external API servers (api.yubico.com through api5.yubico.com). If you ever have a need to override these, you can use `setHosts`:

```
$v = new \Yubikey\Validate($apiKey, $clientId);
$v->setHosts(array(
    'api.myhost1.com',
    'api1.myhost.com'
));
```

Remember, this will *overwrite* the current hosts in the class, so be sure you don't still need those. If you just want to add another host, look at the `addHost` method.

### Multi-Server Requests:

[](#multi-server-requests)

Additonally, the library also supports simultaneous connections to multiple servers. By default it will only make the request to the first server in the `hosts` list. You can enable the multi-server checking with a second parameter on the `check()` method:

```

```

This will make multiple requests and return the pass/fail status of the aggregate responses from each. So, if you have all but one server pass, the overall response will be a fail. If all return `OK` though, you're in the clear.

### "First in" result

[](#first-in-result)

Additionally, you can also switch on and off this aggregation of the results and go with only the "first in" response. You do this with a flag on the `success` checking method:

```

```

**NOTE:** This will still work without multi-server checking. The "first in" will just always be the single response.

@author Chris Cornutt

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity52

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 72.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

Every ~225 days

Recently: every ~92 days

Total

20

Last Release

532d ago

Major Versions

1.2 → 2.02014-10-16

2.6 → 3.02014-11-19

PHP version history (2 changes)1.0PHP &gt;=5.3.1

3.4PHP &gt;=7.4

### Community

Maintainers

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

---

Top Contributors

[![enygma](https://avatars.githubusercontent.com/u/66796?v=4)](https://github.com/enygma "enygma (31 commits)")[![mbolli](https://avatars.githubusercontent.com/u/722725?v=4)](https://github.com/mbolli "mbolli (5 commits)")[![tylermenezes](https://avatars.githubusercontent.com/u/173390?v=4)](https://github.com/tylermenezes "tylermenezes (2 commits)")[![jGielen](https://avatars.githubusercontent.com/u/4853518?v=4)](https://github.com/jGielen "jGielen (1 commits)")[![matason](https://avatars.githubusercontent.com/u/192593?v=4)](https://github.com/matason "matason (1 commits)")[![ishanvyas22](https://avatars.githubusercontent.com/u/17404636?v=4)](https://github.com/ishanvyas22 "ishanvyas22 (1 commits)")[![Potherca](https://avatars.githubusercontent.com/u/195757?v=4)](https://github.com/Potherca "Potherca (1 commits)")[![sarciszewski](https://avatars.githubusercontent.com/u/3710836?v=4)](https://github.com/sarciszewski "sarciszewski (1 commits)")

---

Tags

phpsecuritytokenyubikeyapiresttwofactoryubikeyyubico

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/enygma-yubikey/health.svg)

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

###  Alternatives

[xendit/xendit-php

Xendit PHP SDK

189730.6k6](/packages/xendit-xendit-php)[angelleye/paypal-php-library

PHP wrapper for PayPal APIs

243440.9k](/packages/angelleye-paypal-php-library)[infobip/infobip-api-php-client

PHP library for consuming Infobip's API

921.8M10](/packages/infobip-infobip-api-php-client)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[mediamonks/rest-api-bundle

MediaMonks Rest API Symfony Bundle

1656.2k1](/packages/mediamonks-rest-api-bundle)[phrest/api

REST API Package for Phalcon PHP

304.2k](/packages/phrest-api)

PHPackages © 2026

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