PHPackages                             innoscience/passwordly - 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. innoscience/passwordly

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

innoscience/passwordly
======================

An absurdly simple package for generating and validating random requirement-based passwords for PHP.

1.0.0(12y ago)11.9kGPLv2PHPPHP &gt;=5.3.0

Since Mar 25Pushed 12y ago1 watchersCompare

[ Source](https://github.com/innoscience/passwordly)[ Packagist](https://packagist.org/packages/innoscience/passwordly)[ Docs](https://github.com/innoscience/passwordly)[ RSS](/packages/innoscience-passwordly/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Passwordly
==========

[](#passwordly)

An absurdly simple package for generating and validating random requirement-based passwords for PHP.

[![Build Status](https://camo.githubusercontent.com/41f5bd29b1234259e11ea9a1846b4bbdbeebd4b3f6dddaa0f974881c4c43a29c/68747470733a2f2f7472617669732d63692e6f72672f696e6e6f736369656e63652f70617373776f72646c792e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/innoscience/passwordly)

Copyright (C) 2014 Brandon Fenning

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

[](#requirements)

Compatible with PHP 5.3+

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

[](#installation)

Add `innoscience/passwordly` to the `composer.json` file:

```
"require": {
    "innoscience/passwordly": "dev-master"
}

```

After this, run `composer update`

Usage
-----

[](#usage)

Passwordly is namespaced to `innoscience/passwordly/passwordly`, at the top of your file you'll want to use:

```
use Innoscience\Passwordly\Passwordly;

```

### Creating passwords

[](#creating-passwords)

When creating passwords, Passwordly first checks what the character requirements are. Any difference is made up with the addition of randomly cased alphanumeric characters.

\#####Basic: generate random 8 character password, no symbols $password = Password::can()-&gt;generate(8);

\#####Password with 1 - 3 symbols and 8 - 16 characters in length $password = Password::can()-&gt;hasSymbols(1,3)-&gt;generate(8, 16);

\#####Password with at least 1 uppercase, lowercase and numeric character and 8 characters in length $password = Password::can()-&gt;hasLower(1)-&gt;hasNumbers(1)-&gt;hasUpper(1)-&gt;generate(8);

### Checking password

[](#checking-password)

\#####Check that password has at least 1 number and upper case letter and is at least 8 characters in length $isOk = Password::can()-&gt;hasNumbers(1)-&gt;hasUpper(1)-&gt;hasLength(8)-&gt;check($password);

\#####Check that password has no more than 1 to 3 numbers, 1 symbol and upper case letter and is at least 8 but not more than 16 characters in length $isOk = Password::can()-&gt;hasNumbers(1,3)-&gt;hasUpper(1)-&gt;hasSymbols(1)-&gt;hasLength(8,16)-&gt;strict()-&gt;check($password); When checking passwords, Passwordly does not use the maximum argument unless the `->strict()` method is invoked.

\#####Check password and get errors $passwordCheck = new Passwordly(); $isOk = $passwordCheck-&gt;hasNumbers(1)-&gt;hasUpper(1)-&gt;check($password); $errors = $passwordCheck-&gt;errors(); // # Returns array with each failed requirement

Details
-------

[](#details)

### Instantiating

[](#instantiating)

Passwordly can be instantiated either via the `Passwordly::can()` static constructor or simply by calling `new Passwordly`. Reading the error messages requires access to the Passwordly instance, so chaining calls off of `Passwordly::can()` is not recommended for those use-cases.

### Chainable Methods

[](#chainable-methods)

- `hasLower($min, $max = null)` : The min/max number of lower-case characters that can be in a password.
- `hasUpper($min, $max = null)` : The min/max number of upper-case characters that can be in a password.
- `hasNumbers($min, $max = null)` : The min/max number of numeric characters that can be in a password.
- `hasSymbols($min, $max = null)` : The min/max number of non-alphanumeric characters that can be in a password.
- `hasSpaces($min, $max = null)` : The min/max number of spaces that can be in a password.
- `hasLength($min, $max = null)` : The min/max length of the password.
- `strict()` : Tells `check()` to also enforce the `$max` argument for all chainable methods

### Final Methods

[](#final-methods)

- `generate($min, $max = null)` : Generate a password of $min/$max size from the set requirements, returns a `string`
- `check($password)` : Check the password against the set requirements, returns `true` or `false`

### Other Methods

[](#other-methods)

- `errors()` : Returns an `array` of errors resulting from a `->check()`

### Utility Methods

[](#utility-methods)

These utility methods affect all instances of Passwordly when used.

- `Passwordly::setLowerPool($characterPool)` : Override the lower-case character pool
- `Passwordly::setUpperPool($characterPool)` : Override the upper-case character pool
- `Passwordly::setNumberPool($characterPool)` : Override the numeric character pool
- `Passwordly::setSymbolPool($characterPool)` : Override the symbol character pool
- `Passwordly::getLowerPool()` : Get the lower-case character pool
- `Passwordly::getUpperPool()` : Get the upper-case character pool
- `Passwordly::getNumberPool()` : Get the numeric character pool
- `Passwordly::getSymbolPool()` : Get the symbol character pool
- `Passwordly::setDisableOpenssl($bool)` : Passwordly uses the `openssl_random_pseudo_bytes()` function in php to generate random strings, if this is unavailable use this method and set it to `TRUE` to use a built-in alternative function.

### Tests

[](#tests)

Passwordly is fully unit tested. Tests are located in the `tests` directory of the Passwordly package and can be run with `phpunit` in the package's base directory.

License
-------

[](#license)

Passwordly is licensed under GPLv2

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

4433d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1737fa1e0d9eeac8c269552378baae6b17f491b20290da29d69f6575574d794a?d=identicon)[innoscience](/maintainers/innoscience)

---

Top Contributors

[![innoscience](https://avatars.githubusercontent.com/u/6894281?v=4)](https://github.com/innoscience "innoscience (3 commits)")

---

Tags

password

### Embed Badge

![Health badge](/badges/innoscience-passwordly/health.svg)

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

###  Alternatives

[rollerworks/password-strength-validator

Password-strength validator for Symfony

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

Password-strength validator bundle for Symfony

1433.7M6](/packages/rollerworks-password-strength-bundle)[schuppo/password-strength

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

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

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

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

Prevent users from reusing recently used passwords

86214.4k](/packages/infinitypaul-laravel-password-history-validation)[jbafford/password-strength-bundle

Provides a password strength validator

28468.6k](/packages/jbafford-password-strength-bundle)

PHPackages © 2026

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