1. Go to this page and download the library: Download vperyod/auth-handler 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/ */
vperyod / auth-handler example snippets
// Create handler with Auth and ResumeService instance
$handler = new Vperyod\AuthHandler\AuthHandler($auth, $resume);
// Optionally set the `AuthAttribute`, the name of the attribute on which to
// store the `AuthAttribute` in the `Request`. Defaults to 'aura/auth:auth'
$handler->setAuthAttribute('auth');
// Add to your middleware stack, radar, relay, etc.
$stack->middleware($handler);
// Subsequest dealings with `Request` will have the `Auth` instance available at
// the previous specified atribute
$auth = $request->getAttribute('auth');
// The `AuthRequestAwareTrait` should make dealings easier.
//
// Have all your objects that deal with the auth attribute on the request use
// the `AuthRequestAwareTrait` and have your DI container use the setter, so that
// they all know where the auth object is stored.
class MyMiddleware
{
use \Vperyod\AuthHandler\AuthRequestAwareTrait;
public function __invoke($request, $response, $next)
{
$auth = $this->getAuth($request);
$status = $this->getAuthStatus($request);
$isValid = $this->isAuthValid($request);
// ...
return $next($request, $response);
}
}
class MyInputExtractor
{
use \Vperyod\AuthHandler\AuthRequestAwareTrait;
public funciton __invoke($request)
{
return [
'auth' => $this->getAuth($request),
'data' => $request->getParsedBody()
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.