afaanbilal/php-random-string

Generate a random string of variable length from a given charset

Maintainers

Package info

github.com/AfaanBilal/php-random-string

pkg:composer/afaanbilal/php-random-string

Statistics

Installs: 2 628

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

0.1.1 2026-01-29 02:45 UTC

This package is auto-updated.

Last update: 2026-03-01 00:34:16 UTC


README

Author: Afaan Bilal

Introduction

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

Installation

composer require afaanbilal/php-random-string

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

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

PHP Random String is released under the MIT License. Check out the full license here.