myerscode/utilities-random

A PHP utility class that creates a fluent random value generator

Maintainers

Package info

github.com/myerscode/utilities-random

pkg:composer/myerscode/utilities-random

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

2026.0.0 2026-04-01 09:21 UTC

README

A fluent PHP utility class to help create random values.

⚠️ This package is designed for generating random strings, codes, and identifiers — not for cryptographic purposes. Do not use it for passwords, tokens, or anything requiring cryptographic security.

Latest Stable Version Total Downloads PHP Version Require License Tests codecov

Requirements

  • PHP 8.5+

Install

composer require myerscode/utilities-random

Usage

use Myerscode\Utilities\Random\Drivers\AlphaNumericDriver;
use Myerscode\Utilities\Random\Utility;

$utility = new Utility(AlphaNumericDriver::class);

// Generate a random string of length 5
$random = $utility->generate();

// Generate with custom length
$random = $utility->length(10)->generate();

// Generate chunked values
$random = $utility->length(4)->chunks(3)->spacer('-')->generate();
// e.g. "aB3x-Kp9z-mN2q"

// Generate unique values
$unique = $utility->length(10)->unique();

Documentation

  • Usage — full API reference and usage examples
  • Drivers — built-in drivers and creating custom ones
  • Constraints — constraining generation with pool filters and output constraints

License

MIT