zxcvbn-php symfony bundle

Installs: 98

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 2

Forks: 1

Open Issues: 0


1.0.0 2020-05-15 07:33 UTC

This package is not auto-updated.

Last update: 2020-09-18 09:49:12 UTC


Scrutinizer Code Quality Code Coverage Build Status Packagist

Zxcvbn Symfony Bundle

A bundle to integrate zxcvbn-php with your symfony app. Supports localization and custom matchers.


composer require createnl/zxcvbn-bundle

Basic Usage

use Createnl\ZxcvbnBundle\ZxcvbnFactoryInterface;

class PasswordController
    public function updatePassword(string $password, ZxcvbnFactoryInterface $zxcvbnFactory)
        $userData = [

        $zxcvbn = $zxcvbnFactory->createZxcvbn();

        $weak = $zxcvbn->passwordStrength($password, $userData);
        echo $weak['score']; // will print 0
        $strong = $zxcvbn->passwordStrength('correct horse battery staple');
        echo $strong['score']; // will print 4

        echo $weak['feedback']['warning']; // will print user-facing feedback on the password, set only when score <= 2
        echo $weak['feedback']['suggestions']; // may contain user-facing suggestions to improve the score


This package supports the localization of warning and suggestion messages. Checks on common passwords, words and (family) names are only in English (US). But you can tag your own matcher to extend to your needs.

Supported languages:

  • Dutch 🇳🇱
  • English 🇺🇸

More about localization in Symfony.

Adding translations

If you are missing translations in your language you may consider creating (and contribute) them.

Override in your project:

  1. Open messages.en.yaml
  2. Copy the contents to your project's translation file
  3. Change to your needs

Contributing a language:

  1. Fork this repository
  2. Copy messages.en.yaml
  3. Change the filename to messages.LOCALE.yaml (for example
  4. Open it up and translate the right-hand values to your language
  5. Create a Pull Request
  6. Thank you!

Extending matchers

If you created your own matcher you can tag them with zxcvbn.matcher in your service container.

    resource: '../src/ZxcvbnMatchers'
    tags: ['zxcvbn.matcher']