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($container, $router, $config)
$container->use(Config::class)->set('Auth', $options);
$container->singleton(Auth::class);
$auth = $container->use(Auth::class);
$access = $auth->access();
$auth->addAuthenticator($authenticator, $key);
$user = $auth->attempt($identifier, $password, $rememberMe);
$authenticator = $auth->authenticator($key);
$authenticators = $auth->authenticators();
$url = $auth->getLoginUrl($redirect);
$identifier = $auth->identifier();
$isLoggedIn = $auth->isLoggedIn();
$auth->login($user, $rememberMe);
$auth->logout();
$user = $auth->user();
$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);
$user = $identifier->attempt($identifier, $password);
$identifierFields = $identifier->getIdentifierFields();
$model = $identifier->getModel();
$passwordField = $identifier->getPasswordField();
$user = $identifier->identify($identifier);
$user = $authenticator->authenticate($request);
$response = $authenticator->beforeResponse($response);
$authenticator->login($user, $rememberMe);
$authenticator->logout();
use Fyre\Auth\Authenticators\CookieAuthenticator;
$authenticator = new CookieAuthenticator($auth, $options);
use Fyre\Auth\Authenticators\SessionAuthenticator;
$authenticator = new SessionAuthenticator($auth, $session, $options);
use Fyre\Auth\Authenticators\TokenAuthenticator;
$authenticator = new TokenAuthenticator($auth, $options);
use Fyre\Auth\PolicyRegistry;
$policyRegistry = new PolicyRegistry($container, $inflector);
$policyRegistry->addNamespace($namespace);
$policy = $policyRegistry->build($alias);
$policyRegistry->clear();
$namespaces = $policyRegistry->namespaces();
$hasNamespace = $policyRegistry->hasNamespace($namespace);
$policyRegistry->map($alias, $className);
$policyRegistry->removeNamespace($namespace);
$alias = $policyRegistry->resolveAlias($alias);
$policyRegistry->unload($alias);
$policy = $policyRegistry->use($alias);
use Fyre\Auth\Middleware\AuthMiddleware;
$middleware = new AuthMiddleware($auth);
$middleware = $container->use(AuthMiddleware::class);
$response = $middleware->handle($request, $next);
use Fyre\Auth\Middleware\AuthenticatedMiddleware;
$middleware = new AuthenticatedMiddleware($auth);
$middleware = $container->use(AuthenticatedMiddleware::class);
$response = $middleware->handle($request, $next);
use Fyre\Auth\Middleware\AuthorizedMiddleware;
$middleware = new AuthorizedMiddleware($auth);
$middleware = $container->use(AuthorizedMiddleware::class);
$response = $middleware->handle($request, $next);
use Fyre\Auth\Middleware\UnauthenticatedMiddleware;
$middleware = new UnauthenticatedMiddleware($auth);
$middleware = $container->use(UnauthenticatedMiddleware::class);
$response = $middleware->handle($request, $next);