Create recovery codes for two factor auth

v0.2.1 2021-08-15 12:26 UTC

This package is auto-updated.

Last update: 2024-07-15 19:09:12 UTC


Latest Stable Version Software License Build Status Code Coverage Scrutinizer Code Quality StyleCI

Generate recovery/backup codes to provide a way for your users to recover from a lost two factor auth, or any problem with it.


Via Composer

$ composer require pragmarx/recovery


Basic array usage

$this->recovery = new PragmaRX\Recovery();



If you are using Laravel or install a package like Collect, you can:


You can also define a different collection function to be used:



Json result


Should give you


Changing the result values/sizes

     ->setCount(8)     // Generate 8 codes
     ->setBlocks(5)    // Every code must have 7 blocks
     ->setChars(16)    // Each block must have 16 chars

Should give you


Numeric or alpha?

     ->numeric()       // Generate numeric only codes
     ->alpha()        // Get back to default alpha generation

Upper, lower and mixed case

     ->lowercase()    // All lower
     ->uppercase()    // All upper
     ->mixedcase()    // Get back to default mixed case

Block separator

Usually - is used as a block separator, but you can change it with:


Change log

Please see CHANGELOG for more information on what has changed recently.


$ composer update
$ vendor/bin/phpunit


Please see CONTRIBUTING for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.