PHPackages                             roave/roave-nonce-utility - 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. roave/roave-nonce-utility

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

roave/roave-nonce-utility
=========================

A utility component for handling nonces

2.0.0(7y ago)54.6k2[1 PRs](https://github.com/Roave/NonceUtility/pulls)PHPPHP &gt;=7.2.0

Since Aug 6Pushed 7y ago5 watchersCompare

[ Source](https://github.com/Roave/NonceUtility)[ Packagist](https://packagist.org/packages/roave/roave-nonce-utility)[ RSS](/packages/roave-roave-nonce-utility/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (8)Versions (8)Used By (0)

Roave\\NonceUtility
===================

[](#roavenonceutility)

[![Build Status](https://camo.githubusercontent.com/bc662d445c7546b454ecf5684777a1d6345a1b852f5c0302a5d1f31869daf93f/68747470733a2f2f7472617669732d63692e6f72672f526f6176652f4e6f6e63655574696c6974792e737667)](https://travis-ci.org/Roave/NonceUtility)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/dbae7221c80379b60a52509e5011e6639ae8331169326e06b79918862c61bf09/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f526f6176652f4e6f6e63655574696c6974792f6261646765732f7175616c6974792d73636f72652e706e673f733d66623938323439613866346234353262333939626330363936663135356265643834343163633830)](https://scrutinizer-ci.com/g/Roave/NonceUtility/)[![Build Status](https://camo.githubusercontent.com/eb7cf15a7da394f3d0c86996d50c5790f1ce3f011b8a75e32f92355b4451f209/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f526f6176652f4e6f6e63655574696c6974792f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Roave/NonceUtility/build-status/master)

A simple module that helps with managing nonces

> Usage of this module assumes that you have already installed and configured the DoctrineModule available here

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

[](#installation)

Install the module by adding the module to your composer file

```
php composer.phar require roave/roave-nonce-utility:~2.0.0

```

After this you must enable the module by adding `Roave\NonceUtility` to your `application.config.php` usually found in the `config` directory in the application root.

Now you need to add an alias for the `Roave\NonceUtility\ObjectManager` to the object manager of your choice.

This is the standard configuration for most `ORM` users

```
'service_manager' => [
  'aliases' => [
    'Roave\NonceUtility\ObjectManager' => 'Doctrine\ORM\EntityManager'
  ]
]
```

The last step is to add an entity resolver for our interface to the doctrine configuration and have that class implement the NonceOwnerInterface

Again for most standard `ORM` users

```
'doctrine' => [
  'entity_resolver' => array(
    'orm_default' => array(
      'resolvers' => [
        NonceOwnerInterface::class => AbstractUserEntity::class,
      ]
    ]
  ]
]
```

And the nonce owner entity class

```
abstract class AbstractUser implements NonceOwnerInterface
{
  public function getId()
  {
    // Return your unique identifier.....
  }
}
```

Usage
-----

[](#usage)

To use the module you simply need aquire the nonce service from the service locator

```
$service = $serviceLocator->get(NonceService::class);
```

The service interface is inlined here

```
interface NonceServiceInterface
{
    /**
     * Create a new nonce
     *
     * @param NonceOwnerInterface $owner
     * @param string              $namespace
     * @param DateInterval|null   $expiresIn
     * @param integer             $length
     *
     * @return NonceEntity
     */
    public function createNonce(NonceOwnerInterface $owner, $namespace = 'default', DateInterval $expiresIn = null, $length = 10);

    /**
     * Consume a nonce
     *
     * @param NonceOwnerInterface $owner
     * @param string              $nonce
     * @param string              $namespace
     * @param RequestInterface    $request
     *
     * @throws Exception\NonceNotFoundException
     * @throws Exception\NonceAlreadyConsumedException
     * @throws Exception\NonceHasExpiredException
     *
     * @return void
     */
    public function consume(NonceOwnerInterface $owner, $nonce, $namespace = 'default', RequestInterface $request = null);
}
```

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 94.6% 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 ~272 days

Recently: every ~288 days

Total

7

Last Release

2658d ago

Major Versions

1.1.0 → 2.0.02019-01-28

PHP version history (2 changes)1.0.0PHP &gt;=5.5.0

1.1.0PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/825f7193bec88275f660c65faab1790ed620948f5dd7a6c96515d1f12609127d?d=identicon)[mac\_nibblet](/maintainers/mac_nibblet)

---

Top Contributors

[![awartoft](https://avatars.githubusercontent.com/u/1127626?v=4)](https://github.com/awartoft "awartoft (35 commits)")[![gabrielsch](https://avatars.githubusercontent.com/u/1733354?v=4)](https://github.com/gabrielsch "gabrielsch (2 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/roave-roave-nonce-utility/health.svg)

```
[![Health](https://phpackages.com/badges/roave-roave-nonce-utility/health.svg)](https://phpackages.com/packages/roave-roave-nonce-utility)
```

###  Alternatives

[zf-commons/zfc-base

A set of genetic (abstract) classes which are commonly used across multiple modules.

1441.1M25](/packages/zf-commons-zfc-base)[bitweb/zf2-cron-module

BitWeb ZF2 module for cron.

1341.6k](/packages/bitweb-zf2-cron-module)

PHPackages © 2026

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