1. Go to this page and download the library: Download remotemerge/totp-php 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/ */
remotemerge / totp-php example snippets
use RemoteMerge\Totp\TotpFactory;
// Create a new TOTP instance
$totp = TotpFactory::create();
// Generate a new secret key for the user
$secret = $totp->generateSecret();
// Output the secret key
echo "Generated Secret Key: $secret\n";
use RemoteMerge\Totp\TotpFactory;
// Create a new TOTP instance
$totp = TotpFactory::create();
// Replace with your secret key
$secret = 'JBSWY3DPEHPK3PXP';
// Generate a TOTP code
$code = $totp->getCode($secret);
echo "Generated TOTP Code: $code\n";
use RemoteMerge\Totp\TotpFactory;
// Create a new TOTP instance
$totp = TotpFactory::create();
// Replace with your secret key and the code to verify
$secret = 'JBSWY3DPEHPK3PXP';
$code = '123456';
// Verify the code
$isValid = $totp->verifyCode($secret, $code);
echo $isValid ? "✅ Code is valid!\n" : "❌ Code is invalid!\n";
use RemoteMerge\Totp\TotpFactory;
// Create a new TOTP instance
$totp = TotpFactory::create();
// Replace with your secret key and user information
$secret = 'JBSWY3DPEHPK3PXP';
$uri = $totp->generateUri($secret, '[email protected]', 'YourApp');
echo "QR Code URI: $uri\n";