The » cryptographically secure pseudo-random number generator (CSPRNG) API provides an easy and reliable way to generate crypto-strong random integers and bytes for use within cryptographic contexts.
This exists as of PHP 7.0.0.