PHPackages                             muffin/tokenize - 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. [Security](/categories/security)
4. /
5. muffin/tokenize

ActiveCakephp-plugin[Security](/categories/security)

muffin/tokenize
===============

Security Tokens

1.1.2(8y ago)1319.0k↓30.8%9[1 PRs](https://github.com/UseMuffin/Tokenize/pulls)1MITPHP

Since Dec 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/UseMuffin/Tokenize)[ Packagist](https://packagist.org/packages/muffin/tokenize)[ Docs](https://github.com/usemuffin/tokenize)[ RSS](/packages/muffin-tokenize/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (7)Used By (1)

Tokenize
========

[](#tokenize)

[![Build Status](https://camo.githubusercontent.com/e993e22bffe737b744e6588e09094af2bb2bc24623d6386bf41054c5c24fdebd/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f5573654d756666696e2f546f6b656e697a652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/UseMuffin/Tokenize)[![Coverage Status](https://camo.githubusercontent.com/805a1a4c0db5702dce9287c9db95fa9acc22b468d5ed09390114707391883be9/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f5573654d756666696e2f546f6b656e697a652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/UseMuffin/Tokenize)[![Total Downloads](https://camo.githubusercontent.com/570bd5b43f12edf46338ffc549ace5a19d6a1a2a7a57c67c17bf6e978aa266b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d756666696e2f746f6b656e697a652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muffin/tokenize)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Security tokens for CakePHP 3.

Why?
----

[](#why)

Ever wanted to force users to activate their account upon registration?

Or maybe just a confirmation link when updating their credentials?

Ok, ok - maybe before cancelling a subscription or better, before sending funds out.

Well, now you can. Attach listeners to your models for sending out emails (or any other notification method of your choice), and you're good to go!

Install
-------

[](#install)

Using [Composer](http://getcomposer.org):

```
composer require muffin/tokenize

```

You then need to load the plugin. You can use the shell command:

```
bin/cake plugin load Muffin/Tokenize --routes

```

or by manually adding statement shown below to `bootstrap.php`:

```
Plugin::load('Muffin/Tokenize', ['routes' => true]);
```

This will ensure that the route for `/verify/:token` style URL is configured.

You can also customize the token's length, lifetime and table through `Configure` as shown below:

```
Configure::write('Muffin/Tokenize', [
    'lifetime' => '3 days', // Default value
    'length' => 32, // Default value
    'table' => 'tokenize_tokens', // Default value
]);
```

You will also need to create the required table. A migration file was added to help you with that:

```
bin/cake migrations migrate --plugin Muffin/Tokenize
```

How it works
------------

[](#how-it-works)

When creating or updating a record, and if the data contains any *tokenized* field(s), a token will automatically be created along with the value of the field(s) in question.

When this happens the `Model.afterTokenize` event is fired and passed the operation's related entity and the associated token that was created for it.

The initial (save or update) operation resumes but without the *tokenized* fields.

The *tokenized* fields will only be updated upon submission of their associated token.

Usage
-----

[](#usage)

To tokenize the `password` column on updates, add this to your `UsersTable`:

```
$this->addBehavior('Muffin/Tokenize.Tokenize', [
    'fields' => ['password'],
]);
```

If instead you wanted to have it create a token both on account creation and credentials update:

```
$this->addBehavior('Muffin/Tokenize.Tokenize', [
    'fields' => ['password'],
    'implementedEvents' => [
        'Model.beforeSave' => 'beforeSave',
        'Model.afterSave' => 'afterSave',
    ],
]);
```

Finally, if you just wish to create a token on the fly for other custom scenarios (i.e. password-less login), you can manually create a token:

```
$this->Users->tokenize($user['id']);
```

The above operation, will return a `Muffin\Tokenize\Model\Entity\Token` instance.

To verify a token from a controller's action:

```
$result = $this->Users->Tokens->verify($token);
```

Patches &amp; Features
----------------------

[](#patches--features)

- Fork
- Mod, fix
- Test - this is important, so it's not unintentionally broken
- Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of their own that I can ignore when I pull)
- Pull request - bonus point for topic branches

To ensure your PRs are considered for upstream, you MUST follow the [CakePHP coding standards](http://book.cakephp.org/3.0/en/contributing/cakephp-coding-conventions.html).

Bugs &amp; Feedback
-------------------

[](#bugs--feedback)

License
-------

[](#license)

Copyright (c) 2015, [Use Muffin](http://usemuffin.com) and licensed under [The MIT License](http://www.opensource.org/licenses/mit-license.php).

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

5

Last Release

2310d ago

Major Versions

1.1.2 → 2.0.0-beta2020-01-21

### Community

Maintainers

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

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

---

Top Contributors

[![ADmad](https://avatars.githubusercontent.com/u/142658?v=4)](https://github.com/ADmad "ADmad (19 commits)")[![jadb](https://avatars.githubusercontent.com/u/33527?v=4)](https://github.com/jadb "jadb (12 commits)")[![josegonzalez](https://avatars.githubusercontent.com/u/65675?v=4)](https://github.com/josegonzalez "josegonzalez (7 commits)")[![phillaf](https://avatars.githubusercontent.com/u/1533572?v=4)](https://github.com/phillaf "phillaf (1 commits)")

---

Tags

cakephpmuffintokenize

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/muffin-tokenize/health.svg)

```
[![Health](https://phpackages.com/badges/muffin-tokenize/health.svg)](https://phpackages.com/packages/muffin-tokenize)
```

###  Alternatives

[cakephp/bake

Bake plugin for CakePHP

11211.2M158](/packages/cakephp-bake)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1862.1M27](/packages/dereuromark-cakephp-ide-helper)[muffin/footprint

CakePHP plugin to allow passing currently logged in user to model layer

95627.2k3](/packages/muffin-footprint)[muffin/throttle

(API) Rate limiting requests in CakePHP

62286.8k](/packages/muffin-throttle)[cakephp-fr/recaptcha

To easily use Google Recaptcha (free CAPTCHA service that protect websites from spam and abuse) in CakePHP projects

1419.3k](/packages/cakephp-fr-recaptcha)[cake17/cakephp-recaptcha

\[DEPRECIATED\] Please use https://github.com/cakephp-fr/recaptcha/

1211.0k1](/packages/cake17-cakephp-recaptcha)

PHPackages © 2026

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