zendframework/zend-math
Zend Math provides math utilities for PHP, including big integer/decimal support, random number generation, and statistical helpers. Part of the Zend Framework ecosystem, it offers consistent, tested components for numeric operations.
Install via Composer: composer require zendframework/zend-math. Despite being archived and last released in 2018, it remains compatible with modern PHP (7.1+). Begin by using its three core components: BigInteger for arbitrary-precision integers, Random for cryptographically secure randomness, and bcrypt for secure password hashing (as a drop-in for legacy systems). The most common immediate use case is generating secure tokens or nonces with Random::string($length, Random::STRING_ALNUM).
Zend\Math\BigInteger\BigInteger for modular arithmetic in crypto workflows (e.g., RSA key generation), especially when gmp isn’t available. Example: $big = new BigInteger('12345678901234567890'); $big->add('1');Random::getBytes() or Random::getInt() over mt_rand() for security-sensitive operations like token generation, CSRF salts, or password resets. Integrate via: Random::getString(32, Random::STRING_BYTES);Zend\Crypt\Password\Bcrypt. Avoid for new projects—use password_hash() instead. If needed, verify via Bcrypt::create()->verify($password, $hash).random_bytes(), openssl_random_pseudo_bytes(), hash_pbkdf2()) for new work. Use only where legacy dependencies exist (e.g., upgrading old Zend Framework apps).ext-mbstring: Ensure it’s enabled; Random falls back to insecure methods if unavailable.bitwiseAnd()) when possible.Zend\Math\Rand is deprecated—replace all references with Zend\Math\Random.Zend\Math\*, you can safely require it even if other libraries pull in newer Zend components.How can I help you explore Laravel packages today?