PHPackages                             neophp/passwordstrength-package - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. neophp/passwordstrength-package

ActiveLibrary

neophp/passwordstrength-package
===============================

Configurable password strength validator with optional live UI for NeoPHP

v0.2.2(yesterday)06↑2900%MITPHPPHP &gt;=8.5CI passing

Since Aug 8Pushed yesterdayCompare

[ Source](https://github.com/NeoPHP-Dev/neo-passwordstrength-package)[ Packagist](https://packagist.org/packages/neophp/passwordstrength-package)[ RSS](/packages/neophp-passwordstrength-package/feed)WikiDiscussions main Synced today

READMEChangelog (4)DependenciesVersions (5)Used By (0)

PasswordStrength Package
========================

[](#passwordstrength-package)

A configurable password strength validator for NeoPHP. Define your rules once, in PHP, and use them for real server-side validation — the optional Twig macro and JS engine read the exact same configuration, so there is never a mismatch between what the UI shows and what the server actually enforces.

---

Structure
---------

[](#structure)

```
passwordstrength-package/
├── composer.json
├── README.md
└── src/
    ├── NeoPasswordStrengthPackage.php
    ├── Service/
    │   ├── PasswordStrengthFactory.php
    │   └── PasswordStrengthConfig.php
    ├── Assets/
    │   ├── css/passwordstrength.css
    │   └── js/
    │       ├── strength-engine.js
    │       └── passwordstrength.js
    └── Templates/
        └── components/
            └── PasswordStrength.macro.html.twig

```

---

Three levels of usage
---------------------

[](#three-levels-of-usage)

This package does not force any particular UI on you. Pick the level that fits your project.

### Level 1 — Full package: validation + default UI

[](#level-1--full-package-validation--default-ui)

The simplest path. Configure the rules once, pass the config to the macro, get a password field with a live strength bar and a criteria checklist, styled and functional out of the box.

```
public function registerForm(PasswordStrengthFactory $factory): Response
{
    $passwordConfig = $factory->configure()
        ->setMinLength(10)
        ->requireUppercase()
        ->requireNumber()
        ->requireSpecialChar();

    return $this->render('register.html.twig', ['passwordConfig' => $passwordConfig]);
}
```

```
{% import '@PasswordStrength/components/PasswordStrength.macro.html.twig' as PasswordStrength %}

{{ PasswordStrength.render('password', passwordConfig) }}

```

Then validate the submission with the exact same rules:

```
public function register(Request $request, PasswordStrengthFactory $factory): Response
{
    $config = $factory->configure()->setMinLength(10)->requireUppercase()->requireNumber()->requireSpecialChar();

    $result = $config->validate($request->getPost('password', ''));

    if (!$result['valid']) {
        return $this->render('register.html.twig', ['errors' => $result['errors']]);
    }

    // ...
}
```

**Tip:** define the config once in a shared method/service so the same rules are never typed twice between the form page and the submit handler.

### Level 2 — Validation only, no UI at all

[](#level-2--validation-only-no-ui-at-all)

Use `PasswordStrengthConfig` as a plain PHP validator. Never touch the macro, the CSS, or the JS — build your own `` with your own styling, and just call `validate()` on submit.

```
$config = $factory->configure()->setMinLength(12)->requireSpecialChar();
$result = $config->validate($submittedPassword);

if (!$result['valid']) {
    foreach ($result['errors'] as $error) {
        // your own error handling
    }
}
```

### Level 3 — Your own UI, powered by the same JS engine

[](#level-3--your-own-ui-powered-by-the-same-js-engine)

If you want a live strength indicator but with completely custom markup/styling, skip the macro and `passwordstrength.js`, and import `strength-engine.js` directly — it's a pure function with no DOM dependency:

```
import { evaluatePassword } from '/packages-assets/PasswordStrength/js/strength-engine.js';

const config = /* the same shape as PasswordStrengthConfig::toArray(), e.g. rendered as JSON from PHP */;
const result = evaluatePassword(myPasswordInput.value, config);
// { score: 3, criteria: { minLength: true, uppercase: true, ... }, errors: [] }

// build your own bar, your own checklist, however you like
```

---

Installation
------------

[](#installation)

```
php bin/neo package:require neophp/passwordstrength-package --project=MyProject
```

Register it in the project's `Config/app.config.php`:

```
return [
    // ...
    'packages' => [
        \Vendor\NeoPHP\PasswordStrengthPackage\NeoPasswordStrengthPackage::class,
    ],
];
```

No configuration file, no migration.

---

`PasswordStrengthConfig` API
----------------------------

[](#passwordstrengthconfig-api)

MethodPurpose`setMinLength(int)`Default `8``setMaxLength(int)`Default `null` (no limit)`requireUppercase(bool = true)`Default `false``requireLowercase(bool = true)`Default `false``requireNumber(bool = true)`Default `false``requireSpecialChar(bool = true)`Default `false``setSpecialChars(list)`Default `! @ # $ % ^ & * ? - _``validate(string): array{valid, errors, score}`Real server-side validation`toArray()` / `toJson()`The shape consumed by the JS engine`score` is a 0–4 strength estimate based on length and character variety — it is informational and independent from whether the configured required-rules actually pass (a password can score 4 while still failing `requireSpecialChar()` if that rule is on and no special character is present).

---

Important: `passwordstrength.js` is an ES module
------------------------------------------------

[](#important-passwordstrengthjs-is-an-es-module)

The `` tag loading it must include `type="module"`, since it uses `import`/`export`:

```

```

`strength-engine.js`, used on its own (Level 3), is also an ES module — import it with a bundler or directly via `` in your own code.

---

Theming
-------

[](#theming)

Every visual value in the default macro is a CSS custom property scoped to `.ps-wrapper`:

```
.ps-wrapper {
    --ps-bg: #161923;
    --ps-border: #2d3342;
    --ps-text: #e5e7eb;
    --ps-text-muted: #9ca3af;
    --ps-track-bg: #1b2030;
}
```

Strength bar colors (weak → strong) are currently set directly in `passwordstrength.js`, not as CSS variables — override them by editing the `scoreColors` array in your own copy of the script if needed, or build your own UI with Level 3 for full control.

---

What this package does *not* do
-------------------------------

[](#what-this-package-does-not-do)

- No check against known-compromised password lists (e.g. Have I Been Pwned) — that would require an external API call, out of scope for this package
- No password history / reuse prevention
- The scoring heuristic is simple (length + character variety) — it is not a cryptographic entropy calculation

---

License
-------

[](#license)

MIT

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/212323688?v=4)[BBoezio](/maintainers/BenjiLeLoustik)[@BenjiLeLoustik](https://github.com/BenjiLeLoustik)

---

Top Contributors

[![BenjiLeLoustik](https://avatars.githubusercontent.com/u/212323688?v=4)](https://github.com/BenjiLeLoustik "BenjiLeLoustik (12 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")

### Embed Badge

![Health badge](/badges/neophp-passwordstrength-package/health.svg)

```
[![Health](https://phpackages.com/badges/neophp-passwordstrength-package/health.svg)](https://phpackages.com/packages/neophp-passwordstrength-package)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
