PHPackages                             nanuc/laravel-tokenable - 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. nanuc/laravel-tokenable

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

nanuc/laravel-tokenable
=======================

1.0.0(5y ago)011PHPPHP ^7.3|^8.0

Since Jan 30Pushed 5y agoCompare

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

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

This package lets you add tokens to models.

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

[](#installation)

`composer require nanuc/laravel-tokenable`

Usage
-----

[](#usage)

Add the `HasTokens` trait to your model.

Use the following methods:

```
$model->generateToken($lifetime, $type = null, $tokenGenerator = null);
$model->invalidateTokens($type);
$model::byToken($token, $type);
```

Lifetime is in seconds.

### Token Generators

[](#token-generators)

You can create your own token generators. They must extend `Nanuc\LaravelTokenable\Generators\BaseTokenGenerator` and implement the method `generate`.

This is the default token generator:

```
class NumericTokenGenerator extends BaseTokenGenerator
{
    protected $length;

    public function __construct($length = 4)
    {
        $this->length = $length;
    }

    protected function generate()
    {
        $start = 10 ** ($this->length - 1);
        $end = 10 * $start - 1;

        return rand($start, $end);
    }
}
```

Use your token generator like:

```
$yourModel->generateToken(60, 'a-type', new YourTokenGenerator());
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

1979d ago

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/nanuc-laravel-tokenable/health.svg)

```
[![Health](https://phpackages.com/badges/nanuc-laravel-tokenable/health.svg)](https://phpackages.com/packages/nanuc-laravel-tokenable)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.3M17](/packages/kartik-v-yii2-password)[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

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