2017 © Pedro Peláez
 

cakephp-plugin cakephp-token

Easy use token in CakePHP 3

image

erwane/cakephp-token

Easy use token in CakePHP 3

  • Thursday, May 24, 2018
  • by Erwane
  • Repository
  • 2 Watchers
  • 0 Stars
  • 95 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 22 % Grown

The README.md

CakePHP 4 Token plugin

Description

This is a really "simple to use" cakephp 4 plugin for generating and reading temporaries tokens, (*1)

Installation

composer require erwane/cakephp-token:^2.0
bin/cake migrations migrate -p Token

Usage

Generate a token

/**
 * Create a token with data and return the id
 * @param  array  $content   an array of custom data
 * @param  string $expire    expire exprimed in '+6 days +2 hours' format
 * @param  int $length Token length
 * @return string            The token id
 */

$myNewTokenId = \Token\Token::generate(array $content, $expire, 8);

Get token

// return null (expired or not found) or Token entity
$token = \Token\Token::get($tokenId);

Delete token

Tokens deletion can be ignored, they will be destroyed on expire, but sometime you need to delete one token immediately, (*2)

/**
 * Delete token from id or entity
 * 
 * @param \Token\Model\Entity\Token|string $token Token entity or id
 * @return bool True if token was deleted
 */
$result = \Token\Token::delete($token);

Auto cleaning

Each time a token is read, expired tokens are pruned, (*3)

The Versions

24/05 2018

dev-master

9999999-dev

Easy use token in CakePHP 3

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp token

24/05 2018
04/09 2017
27/07 2017
27/07 2017

dev-dev

dev-dev

Easy use token in CakePHP 3

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp token

27/07 2017
27/07 2017
27/07 2017
27/07 2017
27/07 2017