vaibhavpandeyvpz/chokidar

Doctrine powered, symfony/security inspired, simpler authentication system for PHP 5.3+.

Install

composer require vaibhavpandeyvpz/chokidar

# If you would like to use Chokidar\Loader\DoctrineLoader, install doctrine/dbal
composer require doctrine/dbal

Usage

$connection = /** instanceof Doctrine\DBAL\Connection */;

$loader = new Chokidar\Loader\DoctrineLoader($connection);
$guard = new Chokidar\Guard\SessionGuard($loader);

/** @desc To login user with username + password */
$result = $guard->login('username', 'password');
switch ($result) {
    case Chokidar\GuardInterface::RESULT_NOT_FOUND:
        // No user found with this username
        break;
    case Chokidar\GuardInterface::RESULT_MISMATCH:
        // Password did not match with username
        break;
    default:
        // User is now logged in
        break;
}

/** @desc To check if user is currently logged in */
if ($guard->check()) {
    // Logged in
} else {
    // Not logged in
}

/** @desc To logout currently logged in user */
$guard->logout();

License

See LICENSE.md file.