jord-jd / password-suggester
Secure, dependency-free password suggestion strategies for PHP
Fund package maintenance!
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^7.5 || ^9.6 || ^12.0
Replaces
- divineomega/password-suggester: v4.0.0
This package is auto-updated.
Last update: 2026-07-18 11:02:34 UTC
README
Secure, dependency-free password generation for PHP 7.1 through current releases. The default strategies now generate 20 alphanumeric characters, 20 numeric digits, or six random words using cryptographically secure randomness.
Version 4 removes the old Laravel/NIST validation dependency and global application-container mutations. By default, suggestions must contain at least 15 characters. Applications that use a breach blocklist or another password policy can inject their own validator callback.
Installation
To install Password Suggester, run the following Composer command from the root of your project.
composer require jord-jd/password-suggester
Usage
See the following basic usage example.
use JordJD\PasswordSuggester\PasswordSuggester; use JordJD\PasswordSuggester\SuggestionStrategies\AlphanumericStrategy; use JordJD\PasswordSuggester\SuggestionStrategies\NumbersStrategy; use JordJD\PasswordSuggester\SuggestionStrategies\WordsStrategy; require_once __DIR__.'/../vendor/autoload.php'; $passwordSuggester = new PasswordSuggester(); $strategy = new AlphanumericStrategy(); //$strategy = new WordsStrategy(); //$strategy = new NumbersStrategy(); echo $passwordSuggester->suggest($strategy); echo PHP_EOL;
To apply an application-specific policy:
$passwordSuggester = new PasswordSuggester(function ($password) { return strlen($password) >= 20 && !myBreachServiceContains($password); }); $passwordSuggester->setMaxAttempts(250);