This is a polyfill for the new ext-random
extension that will be released with PHP 8.2.
RFC:
- PHP 7.1
- GMP extension
composer require 'arokettu/random-polyfill'
The library is compatible with ext-random
as released in PHP 8.2.0 beta 1.
Random\Randomizer
getInt($min, $max)
getInt()
- Engines
Random\Engine
interfaceRandom\CryptoSafeEngine
interface- Secure Engine:
Random\Engine\Secure
- Mersenne Twister:
Random\Engine\Mt19937
Random\Randomizer
getBytes($length)
shuffleArray($array)
shuffleBytes($bytes)
pickArrayKeys($array, $num)
- Keep updating with fixes from the upcoming betas and release 1.0.0 around PHP 8.2.0 rc 1
- Empty
arokettu/random-polyfill
v1.99 for PHP 8.2.0 users - Other engines
- Maybe
- Some day
- If I have time
- Don't count on it
Read full documentation here: https://sandfox.dev/php/random-polyfill.html
Also on Read the Docs: https://php-random-polyfill.readthedocs.io/
Please file issues on our main repo at GitLab: https://gitlab.com/sandfox/php-random-polyfill/-/issues
The library is available as open source under the terms of the 3-Clause BSD License. See COPYING.adoc for additional licenses.