承接 createnl/zxcvbn-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

createnl/zxcvbn-bundle

最新稳定版本:3.1.0

Composer 安装命令:

composer require createnl/zxcvbn-bundle

包简介

zxcvbn-php symfony bundle

README 文档

README

Scrutinizer Code Quality Coverage Status CI Packagist

Zxcvbn Symfony Bundle

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

Installation

composer require createnl/zxcvbn-bundle

Basic Usage

use Createnl\ZxcvbnBundle\ZxcvbnFactoryInterface;

class PasswordController
{
    public function updatePassword(string $password, ZxcvbnFactoryInterface $zxcvbnFactory)
    {
        $userData = [
          'Marco',
          'marco@example.com'
        ];

        $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
    }
}

Localization

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 🇺🇸
  • French 🇫🇷

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 messages.es.yaml)
  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.

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

统计信息

  • 总下载量: 21.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-01