evotodi/password-meter-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

evotodi/password-meter-bundle

最新稳定版本:8.0.2

Composer 安装命令:

composer require evotodi/password-meter-bundle

包简介

Password meter for symfony 7 that complements https://github.com/HamedFathi/PasswordMeter and passwordmeter.com

README 文档

README

Symfony PhpStorm

Password Meter Symfony Bundle

PasswordMeter is a php equivalent clone of HamedFathi/PasswordMeter for javascript.

Installation

Install the package with:

composer require evotodi/password-meter-bundle

Usage

This bundle provides a single service to generate a password score like passwordmeter.com and HamedFathi/PasswordMeter.

Configuration

# config/packages/evotodi_password_meter.yaml
evotodi_password_meter:
    # Custom password requirements provider class
    requirements_provider: null
    
    # Custom password score range provider class
    score_provider: null

Implementing password requirements

The default requirements are null and will only return a score and status.
Creating a custom requirements provider will give and array of errors that match your custom requirements.

First create a class that implements Evotodi\PasswordMeterBundle\RequirementsInterface and implement the getRequirements method. From the getRequirements method return a new Evotodi\PasswordMeterBundle\Models\Requirements with your desired password requirements.

// src/Service/PasswordMeterRequirementsProvider.php

namespace App\Service;

use Evotodi\PasswordMeterBundle\Interfaces\RequirementsInterface;
use Evotodi\PasswordMeterBundle\Models\Requirements;

class PasswordMeterRequirementsProvider implements RequirementsInterface
{

	public function getRequirements(): Requirements
	{
		return new Requirements(minLength: 10);
	}
}

Then set the following config. You may need to create the config file if it does not exist.

# config/packages/evotodi_password_meter.yaml
evotodi_password_meter:
    requirements_provider: App\Service\PasswordMeterRequirementsProvider

Implementing custom password score range

Create a class that implements Evotodi\PasswordMeterBundle\ScoreRangeInterface and implement the getScoreRange method. From the getScoreRange method return a new array of score ranges.

// src/Service/PasswordMeterScoreProvider.php

namespace App\Service;

use Evotodi\PasswordMeterBundle\Interfaces\ScoreRangeInterface;

class PasswordMeterScoreProvider implements ScoreRangeInterface
{

	public function getScoreRange(): array
	{
		return [
            '40' => 'veryWeak', // 001 <= x <  040
            '80' => 'weak', // 040 <= x <  080
            '120' => 'medium', // 080 <= x <  120
            '180' => 'strong', // 120 <= x <  180
            '200' => 'veryStrong', // 180 <= x <  200
            '_' => 'perfect', //  >= 200
        ];
	}
}

The array must contain at least 2 elements and the last element key must be '_'.

Then set the following config. You may need to create the config file if it does not exist.

# config/packages/evotodi_password_meter.yaml
evotodi_password_meter:
    score_provider: App\Service\PasswordMeterScoreProvider

Contributions

Contributions are very welcome!

Please create detailed issues and pull requests.

Licence

This package is free software distributed under the terms of the MIT license.

Updates

2026-04-24: Add Symfony 8 support. Drop support for Symfony 6. 2024-01-10: Add Symfony 7 support 2023-01-30: Initial release

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固