PHP code example of roave / roave-nonce-utility
1. Go to this page and download the library: Download roave/roave-nonce-utility 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/ */
roave / roave-nonce-utility example snippets
'service_manager' => [
'aliases' => [
'Roave\NonceUtility\ObjectManager' => 'Doctrine\ORM\EntityManager'
]
]
'doctrine' => [
'entity_resolver' => array(
'orm_default' => array(
'resolvers' => [
NonceOwnerInterface::class => AbstractUserEntity::class,
]
]
]
]
abstract class AbstractUser implements NonceOwnerInterface
{
public function getId()
{
// Return your unique identifier.....
}
}
$service = $serviceLocator->get(NonceService::class);
interface NonceServiceInterface
{
/**
* Create a new nonce
*
* @param NonceOwnerInterface $owner
* @param string $namespace
* @param DateInterval|null $expiresIn
* @param integer $length
*
* @return NonceEntity
*/
public function createNonce(NonceOwnerInterface $owner, $namespace = 'default', DateInterval $expiresIn = null, $length = 10);
/**
* Consume a nonce
*
* @param NonceOwnerInterface $owner
* @param string $nonce
* @param string $namespace
* @param RequestInterface $request
*
* @throws Exception\NonceNotFoundException
* @throws Exception\NonceAlreadyConsumedException
* @throws Exception\NonceHasExpiredException
*
* @return void
*/
public function consume(NonceOwnerInterface $owner, $nonce, $namespace = 'default', RequestInterface $request = null);
}
php composer.phar