PHPackages                             mattkirwan/temp-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mattkirwan/temp-token

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

mattkirwan/temp-token
=====================

A nice and simple library which allows you to generate a random token with an accompanying expiration date - perfect for creating 'forgotten password' URL's, however the temporary token could be used for anything.

1.0.7(13y ago)466GPL-2.0PHP

Since Jan 29Pushed 13y agoCompare

[ Source](https://github.com/mattkirwan/temp-token)[ Packagist](https://packagist.org/packages/mattkirwan/temp-token)[ RSS](/packages/mattkirwan-temp-token/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (9)Used By (0)

Temp-Token - A Simple PHP Temporary Token Generator
===================================================

[](#temp-token---a-simple-php-temporary-token-generator)

Why?
----

[](#why)

I needed a temporary password reset token generating when a user 'forgot their password'. Although a nice feature, pulling in dependencies for storage seemed overkill and decided to just spin up a quick library that generated a very unique token (it can be made even more unique via a 'salt' - something unique to that instance) and a expiration DateTime object for that token.

I suppose you could use it for any scenario requiring a temporary, guaranteed to expire token - my use case was simply a password reset link token.

What exactly?
-------------

[](#what-exactly)

Basically this package allows you to generate two things:

1. A unique token
2. An expiration time for the above token

For ease you can simply store these inside a users table once a password has been reset, send the user a link to the unique url - and assuming the token matches and hasn't expired let them reset their password.

Installation:
-------------

[](#installation)

This library is published on packagist.org, to install you will need the following in your projects composer.json:

```
{
	"require": {
		"mattkirwan/temp-token": "1.0.*"
	},
	"minimum-stability": "dev"
}

```

Once you have that, simply run:

```
php composer.phar update

```

and then use...

Usage:
------

[](#usage)

```
require './vendor/autoload.php';

// Instantiate a new TempToken object
$temp_token = new MattKirwan\TempToken\TempToken();

// Optionally set a unique salt (maybe a username?) for more randomness in the token
$temp_token->set_unique_salt($username);

// Optionally set the token lifetime in seconds - defaults to 1 hour (3600 secs)
$temp_token->set_token_lifetime_secs(7200);

// Optionally set a date format for the token expiration DateTime object
$temp_token->set_date_format('d-m-Y');

// Generates a new token and token expiration
$temp_token->generate_token();

// Retrieve the token
$token = $temp_token->get_token();

// Retrieve a token expiration DateTime
$token_expires = $temp_token->get_token_expiration();

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~0 days

Total

8

Last Release

4843d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/258d7296c8e3da3a06997e8054289b14becad5c1a7e473cbaa5c925a4a4c96b2?d=identicon)[mattkirwan](/maintainers/mattkirwan)

---

Top Contributors

[![anthonysterling](https://avatars.githubusercontent.com/u/159960?v=4)](https://github.com/anthonysterling "anthonysterling (1 commits)")[![jamesmills](https://avatars.githubusercontent.com/u/557096?v=4)](https://github.com/jamesmills "jamesmills (1 commits)")

---

Tags

passwordgeneratortokentemporarygeneratecreatetempforgotuser tokenforgetpassword URLpassword link

### Embed Badge

![Health badge](/badges/mattkirwan-temp-token/health.svg)

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

###  Alternatives

[okipa/laravel-table

Generate tables from Eloquent models.

56752.8k](/packages/okipa-laravel-table)[dirape/token

Unique Token Generator For Laravel

28277.4k2](/packages/dirape-token)[kevinlebrun/password.php

Helpers for password generation and validation

17142.3k1](/packages/kevinlebrun-passwordphp)[okipa/laravel-form-components

Ready-to-use and customizable form components.

198.0k1](/packages/okipa-laravel-form-components)

PHPackages © 2026

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