wikimedia/alea
Alea is a PHP port of the Alea pseudo-random number generator, providing fast, seedable, deterministic random values. Useful for simulations, games, and tests where reproducible output matters.
seed → same sequence, which turns a page that can never be cached into one you can cache by seed.hash(userId) → variant) can be done with any hash, but a seeded PRNG lets you go further: per-user content sampling, not just variant labels, computed identically in PHP and in the browser. This is the core product unlock — no round trip, no flicker, no server-side lookup table for assignment.Consider it when:
mt_rand() changed behaviour in PHP 7.1; Alea's sequence won't drift under you, which matters if seeds are persisted or embedded in URLs.mt_srand() globally poisoning unrelated code paths.Look elsewhere when:
random_bytes() / random_int(). Never this.Random\Randomizer with Xoshiro256StarStar gives you native seeded reproducibility with zero dependencies and a vendor-backed future. This is the strongest competing option and should be evaluated first.To executives (30 seconds): "This is a very small, MIT-licensed utility from Wikimedia that makes random choices repeatable — the same seed always produces the same result, in PHP and in the browser. That lets us ship randomized features that are still cacheable and A/B tests that are consistent without a database lookup. Cost is near zero and risk is low because the code is tiny and we can replace it. The caveat is that it's essentially a one-org project with no community momentum, so we should budget a small amount of engineering ownership rather than assume it's a standard dependency."
To engineering (the actual ask):
composer require, construct a generator with a seed derived from user/session/content ID, inject it where randomness is needed. One day of work, plus tests.Randomizer interface and committing golden vectors so a swap to Random\Randomizer (PHP 8.2+) or a vendored port is a contained change.How can I help you explore Laravel packages today?