PHPackages                             ballen/plexity - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. ballen/plexity

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

ballen/plexity
==============

A password complexity checker library.

2.1.1(3y ago)9878.5k↓37.2%3[1 issues](https://github.com/allebb/plexity/issues)[3 PRs](https://github.com/allebb/plexity/pulls)MITPHPPHP &gt;=7.3.0CI failing

Since Jul 3Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/allebb/plexity)[ Packagist](https://packagist.org/packages/ballen/plexity)[ RSS](/packages/ballen-plexity/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (0)

Plexity
=======

[](#plexity)

[![Build](https://github.com/allebb/plexity/workflows/build/badge.svg)](https://github.com/allebb/plexity/actions)[![Code Coverage](https://camo.githubusercontent.com/d5e6dabf2559b284fb8d9e7405637b064ea46ce59349c4ab8af6697cf44a4ab3/68747470733a2f2f636f6465636f762e696f2f67682f616c6c6562622f706c65786974792f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/allebb/plexity)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d4629335e0f98ab00307c2537c739fb7a882378ff474c4a5d338d321243ec347/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c6c6562622f706c65786974792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/allebb/plexity/?branch=master)[![Code Climate](https://camo.githubusercontent.com/d28d976c17f6d2107b99b7de00b57053b7f28e5164b1e94252f3e6776bb7464a/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f616c6c6562622f706c65786974792f6261646765732f6770612e737667)](https://codeclimate.com/github/allebb/plexity)[![Latest Stable Version](https://camo.githubusercontent.com/0e24982d05b6cecc3e41cf392b80e2563676d346fec4309726ee3aa67f27a59d/68747470733a2f2f706f7365722e707567782e6f72672f62616c6c656e2f706c65786974792f762f737461626c65)](https://packagist.org/packages/ballen/plexity)[![Latest Unstable Version](https://camo.githubusercontent.com/3c70a5ef824fba5e0a22aaa90f93e91fed6aefec933af925976d6967c4c765f1/68747470733a2f2f706f7365722e707567782e6f72672f62616c6c656e2f706c65786974792f762f756e737461626c65)](https://packagist.org/packages/ballen/plexity)[![License](https://camo.githubusercontent.com/b874b68308e00069c80f0f0ba6fb1a65804a65f9e8934da41410d124bf439633/68747470733a2f2f706f7365722e707567782e6f72672f62616c6c656e2f706c65786974792f6c6963656e7365)](https://packagist.org/packages/ballen/plexity)

Plexity (Password Complexity) is a password complexity library that enables you to set "rules" for a password (or any other kind of string) that you can then check against in your application.

This library supports the following kind of complexity settings:

- Upper/lowercase character detection
- Number containment
- Special character containment
- Minimum/maximum character detection
- Password age expiry detection
- Detection of previous use such as against a password history datastore.
- Ability to add and check against a configurable list of common passwords/words etc.

Requirements
------------

[](#requirements)

This library is developed and tested against PHP 7.3, 7.4, 8.0, 8.1 and 8.2!

If you need to use an older version of PHP, you should instead install the 1.x version of this library (see below for details).

License
-------

[](#license)

This client library is released under the MIT license, a [copy of the license](https://github.com/allebb/plexity/blob/master/LICENSE) is provided in this package.

Setup
-----

[](#setup)

To install the package into your project (assuming you are using the [Composer](https://getcomposer.org/) package manager) you can simply execute the following command from your terminal in the root of your project folder:

```
composer require ballen/plexity

```

**If you need to use an older version of PHP, version 1.x.x supports PHP 5.6, 7.0, 7.1 and 7.2, you can install this version using Composer with this command instead:**

```
composer require ballen/plexity ^1.0
```

Examples
--------

[](#examples)

A simple example of how you can use the methods to build up a password complexity rule-set and then validate the password.

```
use Ballen\Plexity\Plexity as PasswordValidator;

$password = new PasswordValidator();

$password->requireSpecialCharacters() // We want the password to contain (atleast 1) special characters.
    //->requireSpecialCharacters(5), // We could also specify a specific number of special characters.
    ->requireUpperCase() // Requires the password to contains more than one upper case characters.
    ->requireLowerCase(2) // Requires the password to contains atleast 2 lower case characters.
    ->requireNumericChataters(3); // We want to ensure that the password uses at least 3 numbers!

// An example of passing a password history array, if the password exists in here then we'll disallow it!
$password->notIn([
    'test_password',
    'Ros3bud',
    'mypasSwordh88e8*&|re',
]);
// You can optionally pass in an implementation of PasswordHistoryInterface like so:
//$password->notIn(new CustomPasswordHistoryDatastore()); // Must implement Ballen\Plexity\Interfaces\PasswordHistoryInterface

try {
    $password->check('my_password_string_here');
    echo "Great news! The password passed validation!";
} catch (Ballen\Plexity\Exceptions\ValidationException $exception) {
    die('Password was invalid, the error was: ' . $exception->getMessage());
}
```

Tests and coverage
------------------

[](#tests-and-coverage)

This library is fully unit tested using [PHPUnit](https://phpunit.de/).

I use [GitHub Actions](https://github.com/) for continuous integration, which triggers tests for PHP 7.3, 7.4, 8.0, 8.1 and 8.2 every time a commit is pushed.

If you wish to run the tests yourself you should run the following:

```
# Install the Plexity Library with the 'development' packages this then includes PHPUnit!
composer install

# Now we run the unit tests (from the root of the project) like so:
./vendor/bin/phpunit

```

Code coverage can also be run but requires XDebug installed...

```
./vendor/bin/phpunit --coverage-html ./report

```

Support
-------

[](#support)

I am happy to provide support via. my personal email address, so if you need a hand drop me an email at: ballen@bobbyallen.me.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance49

Moderate activity, may be stable

Popularity43

Moderate usage in the ecosystem

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 98.3% 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 ~210 days

Recently: every ~138 days

Total

14

Last Release

1259d ago

Major Versions

1.0.7 → 2.0.02020-12-23

PHP version history (3 changes)1.0.0PHP &gt;=5.3.0

1.0.6PHP &gt;=5.5

2.0.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4729a376aa8281d9456a90c000e991aa605c96f15251469acd5a7a5c6cdde2e6?d=identicon)[allebb](/maintainers/allebb)

---

Top Contributors

[![allebb](https://avatars.githubusercontent.com/u/767628?v=4)](https://github.com/allebb "allebb (58 commits)")[![soltmar](https://avatars.githubusercontent.com/u/14175459?v=4)](https://github.com/soltmar "soltmar (1 commits)")

---

Tags

stringpasswordrulescomplexityplexity

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ballen-plexity/health.svg)

```
[![Health](https://phpackages.com/badges/ballen-plexity/health.svg)](https://phpackages.com/packages/ballen-plexity)
```

###  Alternatives

[ruler/ruler

A simple stateless production rules engine for modern PHP.

1.1k815.0k3](/packages/ruler-ruler)[rollerworks/password-strength-validator

Password-strength validator for Symfony

1445.9M6](/packages/rollerworks-password-strength-validator)[rollerworks/password-strength-bundle

Password-strength validator bundle for Symfony

1473.8M8](/packages/rollerworks-password-strength-bundle)[schuppo/password-strength

This package provides a validator for ensuring strong passwords in Laravel 4 applications.

1442.7M1](/packages/schuppo-password-strength)[kartik-v/strength-meter

A dynamic strength meter for password input validation with various configurable options.

881.3M6](/packages/kartik-v-strength-meter)[infinitypaul/laravel-password-history-validation

Prevent users from reusing recently used passwords

84245.5k](/packages/infinitypaul-laravel-password-history-validation)

PHPackages © 2026

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