kartik-v/strength-meter
A Yii2 widget that adds a visual password strength meter to forms, using zxcvbn to score passwords and show feedback as users type. Customizable labels, colors, and thresholds help guide stronger password choices.
This release is a good entry point for anyone wiring a password-strength UI into Laravel auth flows: the additions are mostly polish (translations, Bootstrap 4, configurable minimum length) wrapped around a breaking change to plugin initialization and events from enh #21.
Minimal steps:
composer require the package (or pull the updated tag if you already have it), then publish its config and JS/public assets:
php artisan vendor:publish --provider="...\ServiceProvider" --tag=config
php artisan vendor:publish --provider="...\ServiceProvider" --tag=assets
rules block — v1.1.4 adds rules.minLength (defaults to 2), and enh #13 changed how defaults are merged, so review the full merged array rather than just overriding one key.password input, and mirror rules.minLength in your RegisterRequest / PasswordController validation so client and server agree.If you only need server-side enforcement, you can ignore the JS entirely and use the rule/config layer — but the value of the package is really the UI feedback, so plan on both.
Blade integration. Publish a small partial (resources/views/vendor/.../password-field.blade.php or your own) that renders the input plus the wrapper element the plugin expects, and @include it in both register and reset forms. Keep the markup in one place — the Bootstrap 4 support in enh #20 means the wrapper/DOM shape differs from Bootstrap 3, and you do not want that decision scattered across views.
Mirror the rules, don't duplicate them. Treat rules.* as the single source of truth for UX, and your FormRequest as the source of truth for security. A common pattern:
// config/password-strength.php -> rules.minLength
// app/Http/Requests/RegisterRequest.php
'password' => ['required', 'confirmed', Rule::min(config('password-strength.rules.minLength', 8))],
Pass the config into the view so the JS and PHP read the same number:
return view('auth.register', [
'passwordRules' => config('password-strength.rules'),
]);
Event handling after the BC break. Enh #21 reworked plugin initialization and events. Register behaviour via the new event API rather than the old callbacks. Typical workflows:
Bootstrap 4 vs 3. Enh #20 adds Bootstrap 4 support, but you almost certainly have to select it (config flag, template option, or a v4-specific init call). Pick one framework per app — don't try to support both simultaneously in the same layout.
Translations. v1.1.4 adds Serbian, Spanish, Hungarian, and Polish. Publish the language files, set the locale per-request (App::setLocale() or the ?lang middleware), and verify fallback behaviour. If your app already ships its own i18n strings for the field labels, use the package translations for the strength meter text and keep your labels separate.
Extending defaults. Enh #13 ("better extending of default options") means you can now supply a partial options array without clobbering siblings. Pattern: publish config, override only the keys you care about, and let merge logic handle the rest. If you previously re-declared the entire options array to work around merge issues, remove that duplication — it will silently drift from upstream defaults.
Testing. In feature tests, assert your FormRequest rules independently of the JS package. For the UI, a Dusk/Playwright smoke test that types a short password and asserts the strength element updates will catch init regressions (the most likely breakage from #21).
rules.minLength defaults to 2. That is a UX default, not a security policy. Almost everyone should raise it to at least 8 (or whatever your server-side rule enforces). Leaving it at 2 produces a meter that says "strong" for passwords your backend will reject — the worst of both worlds.php artisan vendor:publish --force for assets and clear view/config caches (php artisan optimize:clear). Stale published JS from a previous version is a very common "the BC break still happens" false alarm.sr vs sr_Latn, es vs es_MX), the plugin falls back to English with no error. Verify the string actually changes when you switch locale.minLength from the 2 default, (5) publish new language files if you use non-English locales, (6) remove any full-options overrides you added to work around the old merge behaviour.How can I help you explore Laravel packages today?