PHP code example of groupesti / laravel-password

1. Go to this page and download the library: Download groupesti/laravel-password library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

groupesti / laravel-password example snippets


use Password\Password;

$request->validate([
    'password' => Password::min(12)
        ->letters(1)              // >= 1 letter
        ->mixedCase(1)            // >= 1 uppercase and >= 1 lowercase
        ->numbers(2)              // >= 2 digits
        ->symbols(1)              // >= 1 symbol
        ->upperCase(1, 3)         // min/max bounds per case
        ->allowSpaces(false)
        ->maxConsecutive(3)       // no more than 3 identical characters in a row
        ->maxRepeats(4)           // a character at most 4 times
        ->maxSequential(4)        // no run (abc / 123) longer than 4
        ->noKeyboardPatterns()    // forbid azerty/qwerty
        ->notContainsUserInfo()   // forbid name/email/username
        ->notContains()           // forbidden-word dictionary
        ->normalize()             // NFKC + reject control characters
        ->uncompromised()         // HaveIBeenPwned
        ->blocklists(),           // internal file + DB blocklists
]);

'password' => Password::defaults(),

Password::generate();          // random policy-compliant password
Password::strength($password); // ['bits' => 84, 'level' => 'very_strong', 'score' => 4]

use Password\Traits\ManagesPasswordLifecycle;
use Password\Interfaces\PasswordLifecycle;

class User extends Authenticatable implements PasswordLifecycle
{
    use ManagesPasswordLifecycle;
}

use Password\Rules\NotReused;

$request->validate([
    'password' => [Password::defaults(), NotReused::for($request->user())],
]);

Route::middleware(['auth', 'password.
bash
composer vendor:publish --tag=password-config
php artisan migrate
bash
php artisan vendor:publish --tag=password-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=password-stubs-blade-tailwind
php artisan vendor:publish --tag=password-stubs-blade-bootstrap
php artisan vendor:publish --tag=password-stubs-vue-tailwind
php artisan vendor:publish --tag=password-stubs-vue-bootstrap
bash
php artisan vendor:publish --tag=password-lang