PHP code example of zepekegno / obfuscate-id-bundle
1. Go to this page and download the library: Download zepekegno/obfuscate-id-bundle 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 Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
#[Route('/user/{id}', name: 'user_show')]
public function show(int $id): Response
{
return new Response("Deobfuscated ID: " . $id);
}
#[Route('/user/{id}', name: 'user_show')]
public function show(User $user): Response
{
return new Response("User: " . $user->getId());
}
use Zepekegno\ObfuscateIdBundle\ValueResolver\Attribute\ObfuscateId;
#[Route('/user/{id}', name: 'user_show')]
public function show(#[ObfuscateId(entity: User::class)] User $user): Response
{
return new Response("User: " . $user->getId());
}
use Zepekegno\ObfuscateIdBundle\Attribute\Obfuscate;
#[ORM\Entity]
class User
{
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
#[Obfuscate] // This property will be automatically obfuscated
private ?int $id = null;
}
ini
OBFUSCATE_ID_SECRET="your_secret_key"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.