PHP code example of timtegeler / guardian
1. Go to this page and download the library: Download timtegeler/guardian 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/ */
timtegeler / guardian example snippets
// create a new authentication backend which implements the AuthenticationInterface
$authenticationBackend = new AuthenticationBackend();
// using e.g. mindplay-dk/middleman as a dispatcher for the middleware stack
$response = (new Dispatcher(
[
// inject Guardian with the authentication backend instance
new Guardian($authenticationBackend),
// ... more middlwares e.g. a router
new Router()
]
))->dispatch($request);
interface AuthenticationInterface
{
/**
* @param ServerRequestInterface $request
* @return bool
*/
public function authenticate(ServerRequestInterface $request);
/**
* @return ResponseInterface
*/
public function getAuthenticationFailedResponse();
}