PHPackages                             kaiopiola/keygen - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kaiopiola/keygen

ActivePackage[Utility &amp; Helpers](/categories/utility)

kaiopiola/keygen
================

Pattern-based key generator

1.2.5(3y ago)13639↓50%5[2 issues](https://github.com/kaiopiola/keygen-package/issues)MITPHPPHP ^7.4|^8.0

Since Jan 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/kaiopiola/keygen-package)[ Packagist](https://packagist.org/packages/kaiopiola/keygen)[ RSS](/packages/kaiopiola-keygen/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (1)Versions (10)Used By (0)

Keygen
======

[](#keygen)

[![](https://camo.githubusercontent.com/b87d10645af9958c422fe8c5b4a3533ec370f8a522c48cce63548155bc4ec994/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b61696f70696f6c612f6b657967656e3f636f6c6f723d2532333030464646)](https://packagist.org/packages/kaiopiola/keygen)[![](https://camo.githubusercontent.com/93a243c6e2a1e27ab09ece91881c43740a0c91a799e83669c3309b148d09851a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b61696f70696f6c612f6b657967656e3f636f6c6f723d253233383838383838266c6162656c3d76657273696f6e)](https://packagist.org/packages/kaiopiola/keygen)[![](https://camo.githubusercontent.com/25b3947eeb95cc8022ca1f242b9f7a0a364cb3b9e166aca89437fdea9326ed5e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6b61696f70696f6c612f6b657967656e)](https://packagist.org/packages/kaiopiola/keygen)

### Essa documentação está disponível também em [Português do Brasil](README_pt-BR.MD).

[](#essa-documentação-está-disponível-também-em-português-do-brasil)

***If you find any bug, feel free to [create a new issue](https://github.com/kaiopiola/keygen-package/issues/new?labels=bug)!***

The Keygen plugin is a key or serial generator based on user-defined mask patterns. The plugin is able to generate keys like the example below:

`6W2F-4RJB-KV0Z-ADA6-4SJ2`

It can be used to generate keys for several purposes, some examples are:

- Unique links to reset passwords
- Registration via invitation link
- Two-Factor authentication codes
- File sharing links
- Product redemption keys
- Discount coupons
- Referral codes

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

[](#installation)

Fisrt, run the following command in your project:

```
composer require kaiopiola/keygen
```

Then, call the main class on the PHP file you want to load it:

```
use Kaiopiola\Keygen\Key;
```

How Keygen works
----------------

[](#how-keygen-works)

### How to create a new key

[](#how-to-create-a-new-key)

To create a new key, just instantiate the class in a variable, and then define its configuration parameters, as shown in the example below:

```
# Instantiating class in a variable:
$exampleKey = new Key;

# Setting parameters:
$exampleKey->setPattern("XXXX-NNNN-LLLL"); // Defines the pattern that the code will use to define its new key.
// The letters represent the type of content that can be used in that space, as per the rule:
// X - Any letter or number
// N - Numbers only as defined
// L - Letters only as defined
// Any other characters like dashes, dots, slashes, and even other letters and numbers, will not be replaced.
// If this property is not defined, the following will be used by default: XXXXX-XXXXX-XXXXX

$exampleKey->setNumbers("789"); // Defines the numbers that can compose your key, if not defined, it will use by default "0123456789"
$exampleKey->setLetters("ABC"); // Defines the letters that can compose your key, if not defined, it will use by default "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

$exampleKey->generate(); // Generate your key and return a string value with the result
```

### How to create a new unique key

[](#how-to-create-a-new-unique-key)

You also have the option to generate an unique key to avoid duplicates, using the example below:

```
$exampleKey->setExistingKeys([]); // Defines the existing keys that the code will avoid duplicates. Must be type array.

$exampleKey->generateUnique(); // Generate your key and return a string value with the result
```

This is also compatible with `setPattern`, `setNumbers` and `setLetters` too!

Considerations
--------------

[](#considerations)

This project is open to contributions, whether with suggestions or improvements to the code of any kind. Feel free to participate in its development.

License
-------

[](#license)

MIT License (MIT). Please, read the [License File](LICENSE) for more informations.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 91.2% 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 ~16 days

Recently: every ~33 days

Total

9

Last Release

1455d ago

Major Versions

v0.9 → v1.02022-01-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f0f4bb2c5bee06a36de3ef70e18517c6416a5b494062b5b86647df4f24669d4?d=identicon)[kaiopiola](/maintainers/kaiopiola)

---

Top Contributors

[![kaiopiola](https://avatars.githubusercontent.com/u/35163593?v=4)](https://github.com/kaiopiola "kaiopiola (31 commits)")[![ordago](https://avatars.githubusercontent.com/u/6376814?v=4)](https://github.com/ordago "ordago (3 commits)")

---

Tags

keygenkeygenerationkeygeneratorkeygensphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kaiopiola-keygen/health.svg)

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

PHPackages © 2026

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