PHP code example of fyre / auth

1. Go to this page and download the library: Download fyre/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/ */

    

fyre / auth example snippets


use Fyre\Auth\Auth;

$auth = new Auth();

$auth = Auth::instance();

Auth::setInstance($instance);

$auth->addAuthenticator($authenticator, $key);

$user = $auth->attempt($identifier, $password, $rememberMe);

$authenticator = $auth->authenticator($key);

$authenticators = $auth->authenticators();

$isLoggedIn = $auth->isLoggedIn();

$auth->login($user, $rememberMe);

$auth->logout();

$user = $auth->user();

use Fyre\Auth\Identity;

$user = Identity::attempt($identifier, $password);

$identifierFields = Identity::getIdentifierFields();

$model = Identity::getModel();

$passwordField = Identity::getPasswordField();

$user = Identity::identify($identifier);

Identity::setIdentifierFields($identifierFields);

Identity::setModel($model);

Identity::setPasswordField($passwordField);

use Fyre\Auth\Access;

Access::after($afterCallback);

$result = Access::allows($rule, ...$args);

$result = Access::any($rules, ...$args);

Access::authorize($rule, ...$args);

Access::before($beforeCallback);

Access::clear();

Access::define($rule, $callback);

$result = Access::denies($rule, ...$args);

$result = Access::none($rules, ...$args);

PolicyRegistry::addNamespace($namespace);

PolicyRegistry::clear();

$namespaces = PolicyRegistry::namespaces();

$hasNamespace = PolicyRegistry::hasNamespace($namespace);

$policy = PolicyRegistry::load($alias);

PolicyRegistry::map($alias, $className);

PolicyRegistry::removeNamespace($namespace);

PolicyRegistry::unload($alias);

$policy = PolicyRegistry::use($alias);

$model = $policy->getModel();

$entity = $policy->resolveEntity($args);

$user = $authenticator->authenticate($request);

$response = $authenticator->beforeResponse($response);

$authenticator->login($user, $rememberMe);

$authenticator->logout();

use Fyre\Auth\Authenticators\CookieAuthenticator;

$authenticator = new CookieAuthenticator($options);

use Fyre\Auth\Authenticators\SessionAuthenticator;

$authenticator = new SessionAuthenticator($options);

use Fyre\Auth\Authenticators\TokenAuthenticator;

$authenticator = new TokenAuthenticator($options);

use Fyre\Auth\Middleware\AuthMiddleware;

$middleware = new AuthMiddleware();

$response = $middleware->process($request, $handler);

use Fyre\Auth\Middleware\AuthenticatedMiddleware;

$middleware = new AuthenticatedMiddleware();

$response = $middleware->process($request, $handler);

use Fyre\Auth\Middleware\AuthorizedMiddleware;

$middleware = new AuthorizedMiddleware();

$response = $middleware->process($request, $handler, ...$args);

use Fyre\Auth\Middleware\UnauthenticatedMiddleware;

$middleware = new UnauthenticatedMiddleware($redirect);

$response = $middleware->process($request, $handler);