PHPackages                             tankfairies/luhn - 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. [Templating &amp; Views](/categories/templating)
4. /
5. tankfairies/luhn

ActiveLibrary[Templating &amp; Views](/categories/templating)

tankfairies/luhn
================

Luhn Template Generator

2.0.1(2y ago)05[1 PRs](https://github.com/tankfairies/luhn/pulls)MITPHPPHP ^8.2

Since May 15Pushed 1y agoCompare

[ Source](https://github.com/tankfairies/luhn)[ Packagist](https://packagist.org/packages/tankfairies/luhn)[ Docs](https://tankfairies.com/)[ RSS](/packages/tankfairies-luhn/feed)WikiDiscussions 2.0 Synced 2mo ago

READMEChangelog (10)Dependencies (3)Versions (15)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/eac5bd6bfe3ec5cbe17e7d0f37e42af2ae9da9eeb6eb25d8e641521a434744dc/68747470733a2f2f706f7365722e707567782e6f72672f74616e6b666169726965732f6c75686e2f762f737461626c65)](https://packagist.org/packages/tankfairies/luhn)[![Total Downloads](https://camo.githubusercontent.com/1bc60cd38a18e25b8cb0079533c2531c28c413780260ab55cc6de8f018b42525/68747470733a2f2f706f7365722e707567782e6f72672f74616e6b666169726965732f6c75686e2f646f776e6c6f616473)](https://packagist.org/packages/tankfairies/luhn)[![Latest Unstable Version](https://camo.githubusercontent.com/e1afd0569182744d768ecc169330190314331db3c89d2ec3ca511feaa8b0ad99/68747470733a2f2f706f7365722e707567782e6f72672f74616e6b666169726965732f6c75686e2f762f756e737461626c65)](https://packagist.org/packages/tankfairies/luhn)[![License](https://camo.githubusercontent.com/2381b80ee18a5162a625cf537f567d067805e25eb80df1e754fa12b98a6ab171/68747470733a2f2f706f7365722e707567782e6f72672f74616e6b666169726965732f6c75686e2f6c6963656e7365)](https://packagist.org/packages/tankfairies/luhn)[![Build Status](https://camo.githubusercontent.com/75da3ae9d72be59e3b1ca9e817ca7d8effcabb5dfd60fbce47ba44243c470af5/68747470733a2f2f7472617669732d63692e636f6d2f74616e6b666169726965732f6c75686e2e7376673f6272616e63683d322e30)](https://travis-ci.com/github/tankfairies/luhn)

Luhn
====

[](#luhn)

Templated Luhn generator and validator.

This is an implementation of the Luhn Algorithm for PHP. The Luhn Algorithm is used to validate things like credit cards and national identification numbers. More information on the algorithm can be found at [Wikipedia](http://en.wikipedia.org/wiki/Luhn_algorithm).

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

[](#installation)

Install with [Composer](https://getcomposer.org/):

```
composer require tankfairies/luhn
```

Usage
-----

[](#usage)

Instantiate a new instance of the library:

Generate numeric Luhn e.g. *USR-7950-8874* : -

```
use Tankfairies\Luhn\Luhn;

$luhn = new Luhn(new SimpleNum());
$luhn->setTemplate('USR-####-####');

$token = $luhn->generate();
```

Generate alpha numeric Luhn e.g. *USR-0tm6-e2h4* : -

```
use Tankfairies\Luhn\Luhn;

$luhn = new Luhn(new SimpleAlnum());
$luhn->setTemplate('USR-####-####');

$token = $luhn->generate();
```

Validate a Luhn (returns true or false): -

```
use Tankfairies\Luhn\Luhn;

$luhn = new Luhn();
$luhn->validate('USR-f36x-x79n9');
```

Copyright and license
---------------------

[](#copyright-and-license)

The tankfairies/luhn library is Copyright (c) 2019 Tankfairies () and licensed for use under the MIT License (MIT).

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 89.1% 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 ~145 days

Recently: every ~171 days

Total

13

Last Release

815d ago

Major Versions

v1.3 → 2.0.02024-02-15

PHP version history (3 changes)v1.0.0PHP ^7.3

v1.0.3PHP ^7.1

2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/761e80f0c4632541e235d7d45128d65ace90c65e3c799c11c36a120155eaad58?d=identicon)[tankfairies](/maintainers/tankfairies)

---

Top Contributors

[![tankfairies](https://avatars.githubusercontent.com/u/50480804?v=4)](https://github.com/tankfairies "tankfairies (41 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")

---

Tags

templateluhnchecksum

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/tankfairies-luhn/health.svg)

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

###  Alternatives

[phpoffice/phpword

PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)

7.5k34.7M183](/packages/phpoffice-phpword)[rize/uri-template

PHP URI Template (RFC 6570) supports both expansion &amp; extraction

420137.3M46](/packages/rize-uri-template)[mopa/bootstrap-sandbox-bundle

Seperate live docs from code

256.8k](/packages/mopa-bootstrap-sandbox-bundle)[larablocks/pigeon

A more flexible email message builder for Laravel 5 including chained methods, reusable message configurations, and message layout and template view management.

143.7k](/packages/larablocks-pigeon)

PHPackages © 2026

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