PHPackages                             afaanbilal/php-random-string - 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. afaanbilal/php-random-string

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

afaanbilal/php-random-string
============================

Generate a random string of variable length from a given charset

0.1.1(3mo ago)12.7k↑66.7%MITPHPPHP &gt;=7.0CI passing

Since Jan 24Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/AfaanBilal/php-random-string)[ Packagist](https://packagist.org/packages/afaanbilal/php-random-string)[ RSS](/packages/afaanbilal-php-random-string/feed)WikiDiscussions master Synced 1mo ago

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

PHP Random String
=================

[](#php-random-string)

Author: **[Afaan Bilal](https://afaan.dev)**

Introduction
------------

[](#introduction)

**PHP Random String** is a composer package to generate random strings of variable length from a given charset.

Installation
============

[](#installation)

```
composer require afaanbilal/php-random-string

```

Usage
=====

[](#usage)

```
// Default length is 12 characters
// Default charset is ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
(new \AfaanBilal\RandomString\RandomString())->generate();
// -> Kfx70JiRotb4

// Generate a random string of 20 characters
(new \AfaanBilal\RandomString\RandomString(20))->generate();
// -> 92CYbvtEMXynllOZmNWK

// Generate a random string of 25 characters from capital alphabets only
(new \AfaanBilal\RandomString\RandomString(25, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))->generate();
// -> ZEIXAISRXEHFOADNXNHOIWKSF
```

Contributing
------------

[](#contributing)

All contributions are welcome. Please create an issue first for any feature request or bug. Then fork the repository, create a branch and make any changes to fix the bug or add the feature and create a pull request. That's it! Thanks!

License
-------

[](#license)

**PHP Random String** is released under the MIT License. Check out the full license [here](LICENSE).

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance79

Regular maintenance activity

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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 ~1830 days

Total

2

Last Release

110d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/998502ff0a47420e61b76cff7e5959040379abbd09451ef1dc0160e357b3a2c2?d=identicon)[afaanbilal](/maintainers/afaanbilal)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/afaanbilal-php-random-string/health.svg)

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

###  Alternatives

[bobey/geoip2-geolite2-composer

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

17838.7k1](/packages/bobey-geoip2-geolite2-composer)[raoul2000/yii-simple-workflow

A simple workflow engine for Yii 1

278.2k](/packages/raoul2000-yii-simple-workflow)

PHPackages © 2026

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