1. Go to this page and download the library: Download axy/htpasswd 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/ */
axy / htpasswd example snippets
use axy\htpasswd\PasswordFile;
$file = new PasswordFile('/path/to/.htpasswd');
$file->setPassword('nick', 'password');
$file->setPassword('john', '123456');
$file->save();
$file = new PasswordFile();
$file->setPassword('nick', 'password');
$file->getContent(); // out of the "file" content
$file->save(); // Exception FileNotSpecified
if (!$file->isUserExist('john')) {
echo 'John? I do not known you.';
exit();
}
if (!$file->verify('john', 'password')) {
echo 'You are not John! You are an impostor!';
exit();
}
echo 'Hello, John';
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.