schuppo/password-strength
Laravel validation rule that scores password strength with the zxcvbn estimator and rejects weak passwords. Configure a minimum score, customize error messages, and use it in form requests or inline validation rules. Simple to install and integrate for safer user accounts.
Install the package with Composer:
composer require schuppo/password-strength
For Laravel 4, add the service provider to app/config/app.php:
'Schuppo\PasswordStrength\PasswordStrengthServiceProvider',
On Laravel 5.5+ package discovery should register it automatically; if not, add the provider manually to config/app.php. As of v2.7 the package declares support for Laravel 10.x, so current installs should resolve cleanly on modern Laravel — but still check the installed version constraint against your app's framework version before upgrading.
Look first at the package README and the registered validator class in src/ to confirm the exact rule name and whether the installed version accepts a minimum-score parameter. The package is a thin Laravel wrapper around zxcvbn-style password scoring, so the important details are the rule name, the score threshold, and the validation message.
Your first use case should be registration:
$request->validate([
'password' => 'required|confirmed|password_strength',
]);
This replaces hand-rolled regex complexity rules with a dictionary- and pattern-aware strength check.
Registration and password reset. Apply the rule to both the registration form and the reset-password form. Keep confirmed alongside it so the two password fields match, and keep required so empty values do not reach the strength checker.
Form Requests. Centralize the rule in RegisterRequest, UpdatePasswordRequest, or a shared trait so registration, profile changes, and admin-created users all enforce the same policy:
public function rules(): array
{
return [
'password' => 'required|string|min:8|max:72|confirmed|password_strength',
];
}
Config-driven thresholds. If the installed version accepts a parameter such as password_strength:3, put the threshold in a config file rather than hard-coding it in every form:
'password' => 'required|confirmed|password_strength:' . config('auth.password_min_score'),
API endpoints. The rule works with JSON validation responses. Return the standard 422 payload and keep the same rule in API form requests so web and API policies do not drift.
Custom messages. Add a translation key such as password.password_strength in resources/lang/.../validation.php, or pass a messages() array from the Form Request. Keep the message actionable: “Choose a longer password or a passphrase” is more useful than “Invalid password.”
Pair with hashing, not replace it. The rule checks strength only. Always store Hash::make($request->password) and never persist the plain value.
Client-side UX. Use zxcvbn.js or a strength meter for live feedback, then keep this package as the server-side source of truth. Server-side validation alone gives users a poor experience because they only learn the password is weak after submitting.
User-specific scoring. zxcvbn scores more accurately when it knows the user's name and email. If the Laravel rule does not expose those inputs, either accept the generic score or write a small custom rule around bjeavons/zxcvbn-php and pass user inputs directly.
max:72), and rate-limit registration and reset endpoints.P@ssw0rd1 and accept a long passphrase. That is intentional, but document the policy for users and support staff.Validator::make in unit tests and feature tests for the endpoint. If you manually register custom rules, clear the validator between tests to avoid leakage.bjeavons/zxcvbn-php in your own rule. This package is thin enough that replacing it is usually easier than fighting its defaults.How can I help you explore Laravel packages today?