PHPackages                             fivesqrd/una - 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. fivesqrd/una

ActiveLibrary

fivesqrd/una
============

Simple PHP library for storing and sending OTPs / 2FAs

v0.2.2(6y ago)017PHPPHP &gt;=7.0.0

Since Feb 10Pushed 6y ago1 watchersCompare

[ Source](https://github.com/fivesqrd/una)[ Packagist](https://packagist.org/packages/fivesqrd/una)[ RSS](/packages/fivesqrd-una/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (8)Used By (0)

una
===

[](#una)

Simple PHP library for storing and sending OTPs / 2FAs

Creating an OTP token
---------------------

[](#creating-an-otp-token)

```
Use Una\Adapter;

/* Initialise the factory class with some defaults */
$factory = new Una\Factory([
    'storage'    => Adapter\Storage\BegoAdapter::instance([
        'table' => 'My-Table',
        'aws'   => [
            'region' => 'eu-west-1',
            'credentials'   => [
                'key'    => 'mykey',
                'secret' => 'mysecret',
            ]
        ],
    ]),
    'randomiser' => new Adapter\Randomiser\Numeric([
        'length' => 5
    ]),
    'hasher'     => new Adapter\Hash\Password()
]);

/* Create a fresh token */
$token = $factory->create()
    ->ttl(86400)
    ->notify(function($secret) {
        mail();
    });

echo $token->raw();
echo $token->hashed();

```

Specifying a token's payload

```
$token = $factory->create()
    ->payload($userId)
    ->ttl(86400)
    ->notify(function($secret) {
        mail();
    });

```

Token with complex payload

```
$token = $factory->create()
    ->payload([
        'userId' => $userId,
        'time'   => time()
    ])
    ->ttl(86400)
    ->notify(function($secret) {
        mail();
    });

```

Specifying a secret

```
$token = $factory->create(12345)
    ->notify(function($secret) {
        mail();
    });

echo $token->raw(); //12345

echo $token->hashed();

```

Specifying a custom random generator. Custom generators implement the Una\\Adapter\\Randomisable interface.

```
use Una\Adapter\Randomiser\AlphaNumeric;

$token = $factory->create()
    ->randomise(new AlphaNumeric())
    ->notify(function($secret) {
        mail();
    });

echo $token->raw(); //random alphanumeric value

echo $token->hashed();

```

Overriding the default ttl

```
use Una\Adapter\Randomiser\AlphaNumeric;

$token = $factory->create()
    ->ttl(86400) //24 hours
    ->notify(function($secret) {
        mail();
    });

echo $token->raw(); //random alphanumeric value

echo $token->hashed();

```

Verifying an OTP token
----------------------

[](#verifying-an-otp-token)

```
try {
    $tokens = $factory->fetch($userId, 'My-App');

    /* Verify input against any valid tokens issued */
    $tokens->verify($input);

    /* Successful, invalidate all tokens immediately */
    $tokens->invalidate();

    return true;
} catch (Una\Exception\Storage)
    return 'a usefull message';
} catch (Una\Exception\Notfound)
    return 'a usefull message';
} catch (Una\Exception\Mismatch)
    return 'a usefull message';
} catch (Una\Exception\TokenExpired)
    return 'a usefull message';
}

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

7

Last Release

2275d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7326f7193078067ab21d775e45c06241d8cc03548c6c3191146d840f2e8277ba?d=identicon)[christianjburger](/maintainers/christianjburger)

---

Top Contributors

[![christianjburger](https://avatars.githubusercontent.com/u/43279?v=4)](https://github.com/christianjburger "christianjburger (9 commits)")

### Embed Badge

![Health badge](/badges/fivesqrd-una/health.svg)

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

PHPackages © 2026

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