PHPackages                             malahierba-lab/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. [Caching](/categories/caching)
4. /
5. malahierba-lab/token

AbandonedArchivedLibrary[Caching](/categories/caching)

malahierba-lab/token
====================

Laravel token manager for password reset, account activation... and more. Laravel Cache Facade Based

1.0.1(10y ago)3333MITPHPPHP &gt;=5.5

Since Oct 24Pushed 10y ago1 watchersCompare

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

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

Laravel Token
=============

[](#laravel-token)

A tool for easy public token implementation in some common tasks: password reset, account activation, etc. In general, when need to send a token through mail (for example). We are developed with Laravel 5.x in mind.

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

[](#installation)

Add in your composer.json:

```
{
    "require": {
        "malahierba-lab/token": "~1.0"
    }
}

```

Then you need run the `composer update` command.

How Work
--------

[](#how-work)

The tokens are save using Laravel Cache Facade, so you don't need a table in your database (unless you are using the database cache as driver), so... you don't need alter your current database, and tokens expire automatically without headaches :)

Use
---

[](#use)

***Important**: For documentation purposes, in the examples below, always we assume than you import the library into your namespace using `use Malahierba\Token\Token;`*

You can generate a token for any model (Eloquent/Model) in your project. In this examples below we are using the User Model, but you can use the Model than you need.

**1.- Make a Token Instance**

```
//Get a Model Instance... in this case, a User instance.
$user = User::find(1);

// Create a password reset token instance
// 'password reset' is just a example... you can use the string than you want :)
// so.. if you want a token named 'my token type' just use it as second parameter. No predefined types.
$token = new Token($user, 'password reset');

//You can define the duration, in minutes, until the token expire. Default is 60.
//This example set 15 minutes to expire the token
$token = new Token($user, 'password reset', 15);

//Also you can define the number of chars for token. Default is 48
//This example set token length in 32 chars (and use the default minutes to expire)
$token = new Token($user, 'password reset', null, 32);

//This example set 15 minutes to expire the token and token length in 32 chars
$token = new Token($user, 'password reset', 15, 32);

```

**2.- Get the Token string**

```
$token_str = $token->get();

```

If no previous token exists (or previous token is expired), then you will get a new randomly generated string. If previous token exists (and is not expired yet) then you get that token.

**3.- Check the Token**

You can validate a token entered by an user or when come from url (for example if you mail a link for password reset with the token as parameter):

```
if ($token->check($string))
    // code for token validated

```

**4.- Delete the Token**

When you don't need the token anymore (for example, your user already setup a new password in password reset lifecycle) you can delete it:

```
$token->delete();

```

*The delete method no destroy the token instance, just delete the old token string. If you run $token-&gt;get() you will receive a new token for same user (and same type) because the instance is the same.*

Licence
-------

[](#licence)

This project has MIT licence. For more information please read LICENCE file.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

3859d ago

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

1.0.1PHP &gt;=5.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/9cd1a6bfe1ce32384fbfd071bf0af9fa3c7456554839aaffc02a25cd81e8a40e?d=identicon)[malahierba](/maintainers/malahierba)

---

Top Contributors

[![cristiansantana](https://avatars.githubusercontent.com/u/7772588?v=4)](https://github.com/cristiansantana "cristiansantana (6 commits)")

---

Tags

laraveltokencachepassword-reset

### Embed Badge

![Health badge](/badges/malahierba-lab-token/health.svg)

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

###  Alternatives

[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202541.1k6](/packages/swayok-alternative-laravel-cache)[arifhp86/laravel-clear-expired-cache-file

Remove laravel expired cache file/folder

36128.7k](/packages/arifhp86-laravel-clear-expired-cache-file)[byerikas/cache-tags

Allows for Redis/Valkey cache flushing multiple tagged items by a single tag.

1413.9k](/packages/byerikas-cache-tags)[salehhashemi/laravel-configurable-cache

Configurable Laravel cache manager

2114.5k1](/packages/salehhashemi-laravel-configurable-cache)

PHPackages © 2026

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