PHP code example of nowo-tech / password-strength-bundle

1. Go to this page and download the library: Download nowo-tech/password-strength-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nowo-tech / password-strength-bundle example snippets


Nowo\PasswordStrengthBundle\PasswordStrengthBundle::class => ['all' => true],

use Nowo\PasswordStrengthBundle\Form\PasswordStrengthType;

$builder->add('plainPassword', PasswordStrengthType::class, [
    'policy_mode' => 'level',
    'level' => 'strong',
    'feedback_position' => 'below',
    'ui_framework' => 'bootstrap5',
]);

$builder->add('plainPassword', PasswordStrengthType::class, [
    'policy_mode' => 'conditions',
    'conditions' => [ /* ... */ ],
    'generator_mode' => 'modal',  // off | input | modal
    'generator_count' => 4,       // suggestions in modal
]);

use Nowo\PasswordStrengthBundle\Validator\PasswordStrength;

#[PasswordStrength(policyMode: 'level', level: 'medium')]
public ?string $plainPassword = null;

$builder->add('password', PasswordStrengthType::class, [
    'use_password_toggle' => true,  // false = plain password input
    'generator_mode' => 'input',
]);
bash
php bin/console assets:install
twig
<script src="{{ asset('password-strength.js', 'nowo_password_strength') }}" defer></script>