PHPackages                             ngiusti/random-string-generator - 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. ngiusti/random-string-generator

ActiveLibrary

ngiusti/random-string-generator
===============================

Generates a random string based on a given pattern

v1.0.0(8y ago)01691MITPHPPHP ^7.0

Since Oct 29Pushed 8y ago1 watchersCompare

[ Source](https://github.com/nathaliagiusti/random-string-generator)[ Packagist](https://packagist.org/packages/ngiusti/random-string-generator)[ Docs](https://github.com/nathaliagiusti/random-string-generator)[ RSS](/packages/ngiusti-random-string-generator/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (2)Used By (1)

RandomStringGenerator
=====================

[](#randomstringgenerator)

**Generates a random string based on a given string pattern**

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

[](#installation)

The package can be used by adding `random-string-generator` to your list of dependencies in `composer.json` as following:

```
composer require ngiusti/random-string-generator

```

Usage
-----

[](#usage)

#### Accepted string patterns:

[](#accepted-string-patterns)

Use `l` for lower case letter from a to z

Use `L` for upper case letter from A to Z

Use `d` for digit from 0 to 9

Use `p` for punctuation

#### Punctuation is any character on the following group:

[](#punctuation-is-any-character-on-the-following-group)

`!`, `"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`, `*`, `+`, `,`, `-`, `.`, `/`, `:`, `;`, ``, `?`, `@`, `[`, `\`, `]`, `^`, `_`, `{`, `|`,`}`, `~` and ```

##### Generate a string containing 2 lower case letters followed by 2 digits.

[](#generate-a-string-containing-2-lower-case-letters-followed-by-2-digits)

```
use RandomStringGenerator\RandomStringGenerator;

$generator = new RandomStringGenerator();
$generator->generate('lldd'); // "ol68"
```

##### Generate a string containing 2 upper case letters.

[](#generate-a-string-containing-2-upper-case-letters)

```
use RandomStringGenerator\RandomStringGenerator;

$generator = new RandomStringGenerator();
$generator->generate('LL'); // "VR"
```

##### Generate a string containing 2 punctuations.

[](#generate-a-string-containing-2-punctuations)

```
use RandomStringGenerator\RandomStringGenerator;

$generator = new RandomStringGenerator();
$generator->generate('pp'); // "?!"
```

**Delimiters**

Apart from `l`,`L`,`d` and `p`, any other character is considered a delimiter. Therefore, the pattern `-dl?` is interpreted as : a hyphen followed by a random digit, followed by a random lower case letter, followed by a question mark.

##### Generate a string containing 2 letters followed by a hyphen.

[](#generate-a-string-containing-2-letters-followed-by-a-hyphen)

```
use RandomStringGenerator\RandomStringGenerator;

$generator = new RandomStringGenerator();
$generator->generate('ll-'); // "yz-"
```

**Scape**

In order to generate a string containing the characters `l`,`L`,`d` and `p`as a delimiter you need to use the backslash twice in order to scape it.

##### Generate a string containing 2 digits followed by the letters `lLdp`.

[](#generate-a-string-containing-2-digits-followed-by-the-letters-lldp)

```
use RandomStringGenerator\RandomStringGenerator;

$generator = new RandomStringGenerator();
$generator->generate('dd\\l\\L\\d\\p'); // "39lLdp"
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3120d ago

### Community

Maintainers

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

---

Top Contributors

[![nathaliagiusti](https://avatars.githubusercontent.com/u/20708798?v=4)](https://github.com/nathaliagiusti "nathaliagiusti (11 commits)")

---

Tags

randomstringgeneratorpattern

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ngiusti-random-string-generator/health.svg)

```
[![Health](https://phpackages.com/badges/ngiusti-random-string-generator/health.svg)](https://phpackages.com/packages/ngiusti-random-string-generator)
```

###  Alternatives

[mistic100/randomcolor

Generate attractive random colors

2431.4M6](/packages/mistic100-randomcolor)[ihor/nspl

Non-standard PHP library (NSPL) - functional primitives toolbox and more

381368.5k](/packages/ihor-nspl)[nubs/random-name-generator

A library to create interesting, sometimes entertaining, random names.

135680.2k3](/packages/nubs-random-name-generator)[artem-schander/l5-modular

Modular pattern generator for Laravel

223235.5k](/packages/artem-schander-l5-modular)[gladcodes/keygen

A fluent PHP random key generator.

119668.9k2](/packages/gladcodes-keygen)[genphrase/genphrase

Secure passphrase generator for PHP applications

118302.5k4](/packages/genphrase-genphrase)

PHPackages © 2026

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