Download the PHP package zepekegno/obfuscate-id-bundle without Composer
On this page you can find all versions of the php package zepekegno/obfuscate-id-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zepekegno/obfuscate-id-bundle
More information about zepekegno/obfuscate-id-bundle
Files in zepekegno/obfuscate-id-bundle
Package obfuscate-id-bundle
Short Description Symfony bundle to securely obfuscate and deobfuscate entity IDs in URLs. Provides attributes and Twig filters to handle obfuscation seamlessly within Symfony applications.
License MIT
Homepage https://github.com/zepekegno224/ObfuscateIdBundle
Informations about the package obfuscate-id-bundle
ObfuscateIdBundle
Introduction
ObfuscateIdBundle is a Symfony extension that enables obfuscation of identifiers in URLs and API responses. This new version introduces several improvements, including:
- Automatic obfuscation of IDs when loading fixtures with Doctrine
- Support for dynamic properties via the
#[ObfuscateId]
annotation - Improved Twig filters
- Persistent default key generation when no key is provided
- Preserved compatibility with both entity-based and raw ID controller actions
Installation
Install the bundle via Composer:
Then, activate it in bundles.php
if not automatically enabled:
Configuration
Add the following configuration in config/packages/obfuscate_id.yaml
:
Define the environment variables in .env
:
If OBFUSCATE_ID_SECRET
is not defined, the bundle will automatically generate a persistent default secret key at installation time. This ensures a consistent encryption key across application restarts and deployments.
The persistent IV will also be generated.
Usage
1. Obfuscation in Controllers
Obfuscation is now automatic, meaning you no longer need to manually annotate route parameters. The bundle will automatically deobfuscate IDs in controller actions:
For entity-based routes, it automatically resolves the entity:
You may also use the annotation explicitly to control deobfuscation:
2. Automatic Obfuscation of IDs in Doctrine
When an entity is loaded, its ID is automatically obfuscated.
Add the #[Obfuscate]
annotation to the relevant property:
3. Using Obfuscation in Twig
Use the obfuscate
filter to mask an identifier in a template:
Doctrine Events
The bundle listens for the following events:
- postLoad → Automatically applies obfuscation to loaded entities.
Development
Install dependencies:
Support
If you encounter any issues, open an issue on GitHub. For feature requests, please provide a detailed description of the use case and expected behavior.