PHPackages                             wikimedia/alea - 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. wikimedia/alea

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

wikimedia/alea
==============

PHP port of the (non-cryptographic) Alea pseudo-random number generator

1.0.1(4mo ago)3474.3k—6.3%2MITPHPPHP &gt;=8.1

Since Jul 11Pushed 2mo agoCompare

[ Source](https://github.com/wikimedia/mediawiki-libs-alea)[ Packagist](https://packagist.org/packages/wikimedia/alea)[ Docs](https://www.mediawiki.org/wiki/Alea)[ RSS](/packages/wikimedia-alea/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (7)Used By (2)

alea.php
========

[](#aleaphp)

**alea.php** is a port of the non-cryptographic Alea pseudo-random number generator to PHP.

Alea was designed to be very fast (in JavaScript) and to generate non-platform-dependent repeatable sets of random numbers (when supplied with matching seeds). Given portable seeds (strings or integers, for example), numbers generated by the [JavaScript version of alea](https://github.com/coverslide/node-alea/)will exactly match those generated by this PHP port, and vice-versa.

Install
-------

[](#install)

This package is [available on Packagist](https://packagist.org/packages/wikimedia/alea):

```
$ composer require wikimedia/alea
```

Usage
-----

[](#usage)

```
use Wikimedia\Alea\Alea;

$prng = new Alea(); // add an optional seed parameter
$nextRandom = $prng->random(); // or ->uint32() or ->fract53()
```

We also have the ability to sync up two Alea PRNGs (even across platforms) via the `importState` and `exportState` methods.

```
$prng1 = new Alea(200);

$prng1->random();
$prng1->random();

$prng2 = Alea::createWithState( $prng1->exportState() );

assert( $prng1->random() === $prng2->random() );
assert( $prng1->random() === $prng2->random() );
assert( $prng1->random() === $prng2->random() );
```

Acknowledgements
----------------

[](#acknowledgements)

The Alea code was written (in JavaScript) by Johannes Baagøe, and packaged for npm by [coverslide](https://github.com/coverslide).

Read more on [Johannes' site](https://web.archive.org/web/20120619002808/http://baagoe.org/en/wiki/Better_random_numbers_for_javascript).

The port to PHP was initially done by C. Scott Ananian and is (c) Copyright 2019-2021 Wikimedia Foundation.

Both the original alea codebase and this port are distributed under the MIT license; see LICENSE for more info.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance82

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 53.7% 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 ~474 days

Recently: every ~593 days

Total

6

Last Release

130d ago

Major Versions

0.9.3 → 1.0.02023-02-24

PHP version history (5 changes)0.9.0PHP &gt;= 7.2.0

0.9.2PHP &gt;=7.2.0

0.9.3PHP &gt;=7.2.9

1.0.0PHP &gt;=7.4

1.0.1PHP &gt;=8.1

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

![](https://www.gravatar.com/avatar/3551c2aefb299a0c45807f7677f5b26d8a5be4a4af359b4bf4fabbdd1f2b990e?d=identicon)[cscott](/maintainers/cscott)

---

Top Contributors

[![cscott](https://avatars.githubusercontent.com/u/156080?v=4)](https://github.com/cscott "cscott (22 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (10 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (7 commits)")[![Daimona](https://avatars.githubusercontent.com/u/38216014?v=4)](https://github.com/Daimona "Daimona (1 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (1 commits)")

---

Tags

PRNGalea

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikimedia-alea/health.svg)

```
[![Health](https://phpackages.com/badges/wikimedia-alea/health.svg)](https://phpackages.com/packages/wikimedia-alea)
```

###  Alternatives

[ruafozy/mersenne-twister

Pure-PHP Mersenne Twister

221.4M12](/packages/ruafozy-mersenne-twister)[skywarth/chaotic-schedule

Randomize scheduled command execution time and date intervals

12142.3k](/packages/skywarth-chaotic-schedule)[savvot/random

Deterministic pseudo-random generators library with dozens of useful functions and several sources of randomness

21243.7k5](/packages/savvot-random)[delight-im/random

The most convenient way to securely generate anything random in PHP

2345.4k](/packages/delight-im-random)[5ini99/think-addons

addons package for thinkphp5

1453.2k](/packages/5ini99-think-addons)[metrakit/faker-eddy-malou

Use Eddy Malou sentences for your dummy texts

172.7k](/packages/metrakit-faker-eddy-malou)

PHPackages © 2026

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