1. Go to this page and download the library: Download marcosdipaolo/auth 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/ */
marcosdipaolo / auth example snippets
/** @var PDO $pdoInstance */
$auth = new MDP\Auth\Auth($pdoInstance);
// Setting the users table name
// The table the Auth package is going to interact with:
$auth->setUsersTableName('members'); // default: 'users'
// Setting the table fields the package should manage
$auth->setEmailField('email_address'); // default: 'email'
$auth->setPasswordField('pass'); // default: 'password'
$auth->setUsernameField('alias'); // default: 'username'
// You can do it in one time with the setUsersTableFields method
$auth->setUsersTableFields([
'usernameField' => 'username',
'passwordField' => 'password',
'emailField' => 'email'
]); // boolean, true if at least one field was set
// Set the column that is going to be evaluated for logging in
$auth->setLoginField('email'); // default: 'email'
/** @var \MDP\Auth\Auth $auth */// boolean;v
/** @var MDP\Auth\Authenticatable $user */
$auth->login($user); // logs in a user
/** @var \MDP\Auth\Auth $auth */
// check credentials
$auth->check('yourField', 'youPassword');
// Register a user
$auth->register('john_doe', '[email protected]', 'myPassword'); // bool (true if successful)
$auth->logout(); // logs out whoever was logged in
// Checks if there's someone logged in
$auth->isUserLoggedIn(); // bool
// Returns the logged user
$auth->user(); // MDP\Auth\Authenticatable logged user | null
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.