PHPackages                             black-m13/randomizr - 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. black-m13/randomizr

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

black-m13/randomizr
===================

Generate some random madness.

v2.x-dev(1y ago)08MITPHPPHP &gt;=7.2

Since Sep 18Pushed 1y agoCompare

[ Source](https://github.com/BlackM13/randomizr)[ Packagist](https://packagist.org/packages/black-m13/randomizr)[ RSS](/packages/black-m13-randomizr/feed)WikiDiscussions v2 Synced 1mo ago

READMEChangelogDependencies (1)Versions (1)Used By (0)

Randomizr: generating random madness
====================================

[](#randomizr-generating-random-madness)

Randomizr is a simple package that helps you generate all kinds of random stuff (hashes, strings, numbers, ...). It can even check whether the created random is unique within a given database table or directory.

Table of contents
-----------------

[](#table-of-contents)

1. [Installation](#1-installation)
2. [Usage](#2-usage)
    2.1. [Charsets](#21-charsets)
    2.2. [Aliases](#22-aliases)
    2.3. [Generating unique randoms](#23-generating-unique-randoms)
    2.4. [Using the Facade](#24-using-the-facade)
    2.5. [Additional helpers](#25-additional-helpers)
3. [Customizing](#3-customizing)
    3.1. [Registering custom charsets](#31-registering-custom-charsets)
    3.2. [Registering custom aliases](#32-registering-custom-aliases)
4. Installation

---

```
$ composer require parsidev/randomizr

```

Register the `Service Provider`:

```
'providers' => [
    ...
    Parsidev\Support\Providers\RandomizrServiceProvider::class,
],

// @file app/config/app.php
```

Additionally, you may register an alias for it, though it's not required (you can also use the helper or include the namespace):

```
'aliases' => [
    ...
    'Randomizr' => Parsidev\Support\Facades\Randomizr::class,
],

// @file app/config/app.php
```

To make sure the package will be loaded properly, run:

```
$ composer update

```

2. Usage

---

### 2.1. Charsets

[](#21-charsets)

Randomizr distincs several character sets, which are:

NameContents`num`0123456789`vowel`aeijoy`consonant`bcdfghklmnpqrstvwxyz`special`áäâàæãåāaeéëêèęėēuúüûùūiíïïìiîįīoóöôòõœøōç`space`' '`dash`-`underscore`\_`punctuation`:,.?!()#### Simple usage

[](#simple-usage)

To generate a random using either one of the charset, simply call the `make()` method on the `randomizr()` helper and tell it which charset you want to use:

```
randomizr('vowel')->make();
randomizr('num')->make();
...
```

#### Setting bounderies

[](#setting-bounderies)

The `make()` method accepts 2 (optional) arguments: `$max` and `$min`:

```
// Set the max length to 16
randomizr('consonant')->make(16);

// Set the minimum length to 2
randomizr('num')->make(16, 2);
```

#### Combining charsets

[](#combining-charsets)

You can also mix 'n match different charsets. For example, if you want to generate a random `num`, but also allow a `dash` and an `underscore` in it:

```
randomizr('num_dash_underscore')->make();
// or, if you prefer
randomizr('numDashUnderscore')->make();
```

### 2.2. Aliases

[](#22-aliases)

Though camel- or snake casing is a very convenient way to merge various charsets, you may as well register an alias for it. By default, these are the ones provided:

NameCombines`lowercase``vowel`, `consonant``uppercase`uppercased `lowercase``alpha``uppercase`, `lowercase``string``alpha`, `num`, `dash`, `space`, `underscore`, `punctuation`, '&amp;$@'`hash``alpha`, `num`, `dash`, `underscore`, '&amp;$@'So in fact, `lowercase` is an alias to `vowel_constant`. And lets be honest, it's far more cleaner looking.

#### Combining aliases and/or charsets

[](#combining-aliases-andor-charsets)

As you may have seen it already in the table above, aliases also allow to combine charsets with aliases, or even aliases with each other:

```
// Using charsets only
randomizr('vowel_consonant_num')->make();

// Using the `alpha` alias to merge `vowel` and `consonant`
randomizr('alpha_num')->make();
```

### 2.3 Generating unique randoms

[](#23-generating-unique-randoms)

Randomizr can generate randoms that are unique either in a directory or in a database table using the `unique()` method instead of `make()`.

#### Unique in a directory

[](#unique-in-a-directory)

```
randomizr('alpha_punctuation')->unique('path/to/dir');
```

#### Unique in a database table (for a field)

[](#unique-in-a-database-table-for-a-field)

```
randomizr('lowercase_dash')->unique('tablename@field');
```

> **Note**: Checking for uniqueness against a database table requires the package to run in a Laravel application. You won't be able to use this feature elsewhere.

#### Setting bounderies

[](#setting-bounderies-1)

The same way you can set bouderies for `make()`, you can do it for `unique()`:

```
randomizr('string')->unique('path/to/dir', 16, 6);
```

### 2.4. Using the Facade

[](#24-using-the-facade)

I personally prefer using the helper method (which doesn't require you to put the full namespace at the top of your file), but you can just as well use the `facade` or `alias` (if registered in the app config):

```
randomizr('alpha_num')->make();
// equals
randomizr('alphaNum')->make();
// equals
Randomizr::alpha_num()->make();
// equals
Randomizr::alphaNum()->make();
```

### 2.5. Additional helpers

[](#25-additional-helpers)

In addition to the `randomizr()` helper, a few other helper functions are included that can be used throughout the entire application:

#### Strings

[](#strings)

##### str\_starts\_with

[](#str_starts_with)

`str_starts_with` checks if a given string starts with a specified (group of) character(s).

```
str_starts_with('a', 'abc'); // returns true
str_starts_with('b', 'abc'); // returns false
```

##### str\_ends\_with

[](#str_ends_with)

`str_ends_with` checks if a given string ends with a specified (group of) character(s).

```
str_ends_with('de', 'abcde'); // returns true
str_ends_with('cd', 'abcde'); // returns false
```

3. Customizing

---

Several charsets and aliases are available by default, but you can add your own ones if you like. All you need to do is config the Randomizr config file:

```
$ php artisan randomizr:publish

```

The config file will be published to `app/config/packages/luminol/randomizr/randomizr.php`.

> **Note**: I made a custom artisan command for this to keep publishing assets the same for both L4 and L5.

### 3.1. Registering custom charsets

[](#31-registering-custom-charsets)

Registering custom charsets is pretty straight forward. Just add:

```
'charsets' => array(
    ...
    'mycharsetname' => 'characters_for_this_charset'
),
```

> **Important**: Charset names should always consise of one word only. Do not use snake- or camel casing (it'll break the combine functionality).

### 3.2. Registering custom aliases

[](#32-registering-custom-aliases)

Custom aliases are a bit more configurable: it uses piping to separate the different components to combine. These components can be a raw `string`, `charset` or `alias` and can even be altered using a basic string functions.

To illustrate all of this, let's image you need to generate a random ID, which can contains alpha characters (both upper- and lowercase), dashes and '.'.

#### Combining charsets and/or aliases

[](#combining-charsets-andor-aliases)

The example above tells us the ID alias may contain alpha characters (which is an alias) and dashes (which is a charset). So to combine them in the `id` alias:

```
'aliases' => array(
    ...
    'id' => "alpha|dash"
),
```

Randomizr will automatically resolve these as an alias and a charset.

#### Adding a raw string to an alias

[](#adding-a-raw-string-to-an-alias)

In our example above, we also need a '.' (dot) to be added. It is available in the `punctuation` charset, but all other characters in this one are not allowed in the ID alias.

We could register the single dot as a charset, but we can also pass it as a raw string to the alias. Just wrap it between `single quotes`:

```
'aliases' => array(
    ...
    'id' => "alpha|dash|'.'"
),
```

If you want to add a raw number to the alias, no need to wrap it in single quotes (though it will work as well):

```
'aliases' => array(
    ...
    'id' => "consonant|6", // the result will be 'aeijoy6'
),
```

#### Using simple string functions

[](#using-simple-string-functions)

Aliases also allow basic string functions to be used. For example, you might only want an uppercased version of the `special` charset. In that case, you can seperate the function name and its argument using `method:arg1,arg2` format:

```
'aliases' => array(
    ...
    'uspecial' => "strtoupper:special"
),
```

The functions `arguments` can be a `charset`, an `alias` or even a raw `string` (wrapped in single quotes):

```
'aliases' => array(
    ...
    'notnull'   => "str_replace:0,'',num", // results in '123456789'
    'custom'    => "my_custom_function:'arg1',num"
),
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 92% 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

Unknown

Total

1

Last Release

607d ago

### Community

Maintainers

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

---

Top Contributors

[![parsidev](https://avatars.githubusercontent.com/u/11275201?v=4)](https://github.com/parsidev "parsidev (23 commits)")[![BlackM13](https://avatars.githubusercontent.com/u/100307090?v=4)](https://github.com/BlackM13 "BlackM13 (2 commits)")

---

Tags

randomlaravelgeneratorrandomizr

### Embed Badge

![Health badge](/badges/black-m13-randomizr/health.svg)

```
[![Health](https://phpackages.com/badges/black-m13-randomizr/health.svg)](https://phpackages.com/packages/black-m13-randomizr)
```

###  Alternatives

[dcblogdev/laravel-module-generator

Generate Laravel Modules from a template.

7710.1k1](/packages/dcblogdev-laravel-module-generator)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

295.1k](/packages/linkxtr-laravel-qrcode)[akira/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

431.4k](/packages/akira-laravel-qrcode)

PHPackages © 2026

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