1. Go to this page and download the library: Download knpuniversity/guard 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/ */
knpuniversity / guard example snippets
use KnpU\Guard\Authenticator\AbstractFormLoginAuthenticator;
use KnpU\Guard\...;
// ...
class FormLoginAuthenticator extends AbstractFormLoginAuthenticator
{
// ...
public function checkCredentials($credentials, UserInterface $user)
{
// ...
if ($password !== 'correctPassword') {
throw new AuthenticationException();
}
// do nothing, allow authentication to pass
}
// ...
}
use Symfony\Component\Security\Guard\AbstractFormLoginAuthenticator;
use Symfony\Component\Security\Guard\...;
// ...
class FormLoginAuthenticator extends AbstractFormLoginAuthenticator
{
// ...
public function checkCredentials($credentials, UserInterface $user)
{
// ...
if ($password !== 'correctPassword') {
// returning anything NOT true will cause an authentication failure
return;
// or, you can still throw an AuthenticationException if you want to
// throw new AuthenticationException();
}
// return true to make authentication successful
return true;
}
// ...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.