PHPackages                             pageon/expiring-token - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. pageon/expiring-token

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

pageon/expiring-token
=====================

A cryptographically safe token with a build in customizable expiration date

1.0.3(4y ago)5564MITPHPPHP &gt;=7.0CI failing

Since Feb 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Pageon/ExpiringToken)[ Packagist](https://packagist.org/packages/pageon/expiring-token)[ Docs](https://pageon.github.io/ExpriringToken)[ RSS](/packages/pageon-expiring-token/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

Expiring Token
==============

[](#expiring-token)

[![Build Status](https://camo.githubusercontent.com/5e0d108a761691bfa5316fb018f2bebd059d64fa1adcf09514f73a4f28c938e9/68747470733a2f2f7472617669732d63692e6f72672f506167656f6e2f4578706972696e67546f6b656e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Pageon/ExpiringToken)[![License](https://camo.githubusercontent.com/43cbfab5b9a24fa911d1096ac6ab668258f1cadd9164eedd905c12220403c5a8/68747470733a2f2f706f7365722e707567782e6f72672f706167656f6e2f6578706972696e672d746f6b656e2f6c6963656e73652e737667)](https://packagist.org/packages/pageon/expiring-token)[![Code Coverage](https://camo.githubusercontent.com/073496961cfa89412579f53d86a6588748f8b3788082ae1ccf358fa53ff8010a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f506167656f6e2f4578706972696e67546f6b656e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Pageon/ExpiringToken/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c38401c85b9fd7e7ab633868d4ae0e29832d055bcd431ba1e4d92ce24c57f7e9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f506167656f6e2f4578706972696e67546f6b656e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Pageon/ExpiringToken/?branch=master)

The expiring token generates a random token of 128 characters with an expiration date.

The token uses base64 but the length is calculated so that it is url safe, so no padding with the = character.

The actual token is generated with [random\_bytes](http://php.net/manual/en/function.random-bytes.php) with a length of `32`

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

[](#installation)

You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):

```
composer require pageon/expiring-token

```

Public api
----------

[](#public-api)

### ExpiringToken::create

[](#expiringtokencreate)

You can create a new token this way. It accepts a [DateInterval](http://php.net/manual/en/class.dateinterval.php) as optional parameter to set a different expiration date.

The default expiration date is 3 days.

### ExpiringToken::fromString

[](#expiringtokenfromstring)

Used to create an instance of the token from the string representation

### ExpiringToken::\_\_toString

[](#expiringtoken__tostring)

This turns the class instance into the string version of the token when the instance is used as or cast to a string.

### ExpiringToken::validateAgainst

[](#expiringtokenvalidateagainst)

This can be used to validate the current token against an other token

- When the tokens maths this method will return `true`
- An `InvalidToken` exception will be thrown if the tokens don't match
- An `TokenHasExpired` exception will be thrown if the token has expired

### ExpiringToken::hasExpired

[](#expiringtokenhasexpired)

Returns a bool indicating if the current token has expired

### ExpiringToken::getExpiresOn

[](#expiringtokengetexpireson)

Can be used to get the expiration date of the token

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~529 days

Total

4

Last Release

1781d ago

PHP version history (2 changes)1.0.0PHP ^7.0

1.0.3PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/750f8c93ab277a806e4dc8b164d378e800b55707edc7f98243eea388efb40a4b?d=identicon)[justcarakas](/maintainers/justcarakas)

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

---

Top Contributors

[![carakas](https://avatars.githubusercontent.com/u/3634654?v=4)](https://github.com/carakas "carakas (21 commits)")

---

Tags

expirationforgot-passwordpassword-resetphpphp-7tokentoken-authenticationtokensphptokenpassword-resetexpiringtime sensitivepassword forgotten

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/pageon-expiring-token/health.svg)

```
[![Health](https://phpackages.com/badges/pageon-expiring-token/health.svg)](https://phpackages.com/packages/pageon-expiring-token)
```

PHPackages © 2026

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