PHPackages                             thejawker/super-random - 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. thejawker/super-random

ActiveLibrary

thejawker/super-random
======================

Allows for easy unique code generation, is database aware for Laravel Applications.

v1.0.2(8y ago)027MITPHPPHP &gt;=7.0.0

Since Feb 9Pushed 8y ago1 watchersCompare

[ Source](https://github.com/thejawker/super-random)[ Packagist](https://packagist.org/packages/thejawker/super-random)[ Docs](https://github.com/thejawker/super-random)[ RSS](/packages/thejawker-super-random/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (5)Versions (5)Used By (0)

Generate Database Aware Unique Codes For Laravel
================================================

[](#generate-database-aware-unique-codes-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/835996b14a67c9f4300aac6b3407c3cfaa919a054663638ca7e3a89e9f9211fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7468656a61776b65722f73757065722d72616e646f6d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thejawker/super-random)[![Build Status](https://camo.githubusercontent.com/f474bcc57fb1dbca3845b09e6e3df835b2232ef13d58506dd589eff5f1084c84/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7468656a61776b65722f73757065722d72616e646f6d2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/thejawker/super-random)[![Quality Score](https://camo.githubusercontent.com/ce62835b785a2084bf6da249903dc26be337b16cae42030f4f86a251923f6986/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7468656a61776b65722f73757065722d72616e646f6d2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thejawker/super-random)[![Total Downloads](https://camo.githubusercontent.com/dbcac567ea093a13b8a94eec5e7b402e0a3fbf3458f22bb0540bb35f76009130/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7468656a61776b65722f73757065722d72616e646f6d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thejawker/super-random)

Nice and fluent way to create truly unique codes or tokens.

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

[](#installation)

Require the package from Composer:

```
composer require thejawker/super-random
```

As of Laravel 5.5 it will magically register the package.

Usage
-----

[](#usage)

Just simple call the generate method on SuperRandom Facade or the handy shortcut helper function.

```
$code = SuperRandom::generate();
echo $code; //

$code = superRandom();
```

### Examples:

[](#examples)

#### Database Aware

[](#database-aware)

Often you don't want more than one of the same codes or tokens to be present in your database. Although it's easy to compare to the database it is annoying having to re-implement this all over the place. By specifying the `table.column` in the `for` method you can easily make it entry aware.

```
ConcertTicket::create([
    'band' => 'DYSSEBIA',
    'code' => SuperRandom::for(ConcertTicket::class)->generate()
]);

// Or more explicit:
ConcertTicket::create([
    'band' => 'DYSSEBIA',
    'code' => SuperRandom::for('concerts.code')->generate()
]);
```

### Length

[](#length)

You can specify the length as follows:

```
ConcertTicket::create([
    'band' => 'DYSSEBIA',
    'code' => SuperRandom::length(12)->generate()
]);
```

### Allowed Chars

[](#allowed-chars)

You can specify the allowed chars as follows:

```
ConcertTicket::create([
    'band' => 'DYSSEBIA',
    'code' => SuperRandom::chars('abc123')->generate()
]);
```

By default we only include numbers and UPPERCASE characters with the exclusion of: `1, I, O, 0` since they look a lot alike and you don't want your users to guess.

### Full Config

[](#full-config)

You can alternatively set the config right on the `generate()` method.

```
ConcertTicket::create([
    'band' => 'DYSSEBIA',
    'code' => SuperRandom::generate([
        'table' => 'concerts',
        'column' => 'code',
        'length' => 15,
        'chars' => 'abc123'
    ])
]);
```

Test
----

[](#test)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~3 days

Total

4

Last Release

3006d ago

Major Versions

v0.0.1 → v1.0.02018-02-12

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6703837?v=4)[Bram Veerman](/maintainers/thejawker)[@thejawker](https://github.com/thejawker)

---

Top Contributors

[![thejawker](https://avatars.githubusercontent.com/u/6703837?v=4)](https://github.com/thejawker "thejawker (8 commits)")

---

Tags

randomcode generatoruniquetoken generatorthejawkerdatabase-aware-unique-code-generator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thejawker-super-random/health.svg)

```
[![Health](https://phpackages.com/badges/thejawker-super-random/health.svg)](https://phpackages.com/packages/thejawker-super-random)
```

###  Alternatives

[dirape/token

Unique Token Generator For Laravel

28277.4k2](/packages/dirape-token)[poing/earmark

Laravel package to generate values in a unique and customizable series.

10712.9k](/packages/poing-earmark)[webcraft/laravel-random

Laravel wrapper around paragonie/random-lib

1010.9k](/packages/webcraft-laravel-random)[defiant/randomorg

PHP class and Laravel implementation for Random.org

162.5k](/packages/defiant-randomorg)

PHPackages © 2026

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