PHP code example of laulamanapps / tokenable-symfony
1. Go to this page and download the library: Download laulamanapps/tokenable-symfony 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/ */
use LauLamanApps\Tokenable\Attribute\Tokenable;
#[ORM\Entity]
#[Tokenable(prefix: 'per', prime: 2062703171, inverse: 392512107, random: 628259887)]
class Person
{
public function getId(): PersonId { /* ... */ }
}
#[Route('/people/{person}', name: 'person_show')]
public function __invoke(Person $person): Response
{
// $person is already loaded from the token in the URL.
}
use LauLamanApps\Tokenable\Tokenizer;
public function __construct(private readonly Tokenizer $tokenizer) {}
$token = $this->tokenizer->encode($person); // 'per_3f9k2'
[$class, $id] = $this->tokenizer->decode('per_3f9k2'); // [Person::class, 42]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.