PHPackages                             zepekegno/obfuscate-id-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. zepekegno/obfuscate-id-bundle

ActiveSymfony-bundle[Security](/categories/security)

zepekegno/obfuscate-id-bundle
=============================

Symfony bundle to securely obfuscate and deobfuscate entity IDs in URLs. Provides attributes and Twig filters to handle obfuscation seamlessly within Symfony applications.

v1.1.0(1y ago)1491MITPHPPHP &gt;=8.2CI passing

Since Oct 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/zepekegno224/ObfuscateIdBundle)[ Packagist](https://packagist.org/packages/zepekegno/obfuscate-id-bundle)[ Docs](https://github.com/zepekegno224/ObfuscateIdBundle)[ RSS](/packages/zepekegno-obfuscate-id-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

ObfuscateIdBundle
=================

[](#obfuscateidbundle)

[![Latest Stable Version](https://camo.githubusercontent.com/06ac17915ea91f1ecf7f05cd211dd4f5a8893bb2953a28d92da15e92161f691e/687474703a2f2f706f7365722e707567782e6f72672f7a6570656b65676e6f2f6f62667573636174652d69642d62756e646c652f76)](https://packagist.org/packages/zepekegno/obfuscate-id-bundle) [![Total Downloads](https://camo.githubusercontent.com/c0bc1651cd833c1da6e8455d42be2ec0de85f0ada348f76c8bed8b34ad055375/687474703a2f2f706f7365722e707567782e6f72672f7a6570656b65676e6f2f6f62667573636174652d69642d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/zepekegno/obfuscate-id-bundle) [![License](https://camo.githubusercontent.com/607eeef938678edee579c21de80f654297f0f9e95774f5102db712b437eefffe/687474703a2f2f706f7365722e707567782e6f72672f7a6570656b65676e6f2f6f62667573636174652d69642d62756e646c652f6c6963656e7365)](https://packagist.org/packages/zepekegno/obfuscate-id-bundle) [![PHP Version Require](https://camo.githubusercontent.com/b508a120c758da8ee3d627d31a7aaec9e62df7456c85aa879c182161bf8d6d46/687474703a2f2f706f7365722e707567782e6f72672f7a6570656b65676e6f2f6f62667573636174652d69642d62756e646c652f726571756972652f706870)](https://packagist.org/packages/zepekegno/obfuscate-id-bundle)

Introduction
------------

[](#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
------------

[](#installation)

Install the bundle via Composer:

```
composer require zepekegno/obfuscate-id-bundle
```

Then, activate it in `bundles.php` if not automatically enabled:

```
return [
    Zepekegno\ObfuscateIdBundle\ObfuscateIdBundle::class => ['all' => true],
];
```

Configuration
-------------

[](#configuration)

Add the following configuration in `config/packages/obfuscate_id.yaml`:

```
obfuscate_id:
    secret_key: '%env(OBFUSCATE_ID_SECRET)%'
```

Define the environment variables in `.env`:

```
OBFUSCATE_ID_SECRET="your_secret_key"
```

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
-----

[](#usage)

### 1. **Obfuscation in Controllers**

[](#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:

```
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);
}
```

For entity-based routes, it automatically resolves the entity:

```
#[Route('/user/{id}', name: 'user_show')]
public function show(User $user): Response
{
    return new Response("User: " . $user->getId());
}
```

You may also use the annotation explicitly to control deobfuscation:

```
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());
}
```

### 2. **Automatic Obfuscation of IDs in Doctrine**

[](#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:

```
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;
}
```

### 3. **Using Obfuscation in Twig**

[](#3-using-obfuscation-in-twig)

Use the `obfuscate` filter to mask an identifier in a template:

```
View User
```

Doctrine Events
---------------

[](#doctrine-events)

The bundle listens for the following events:

- **postLoad** → Automatically applies obfuscation to loaded entities.

Development
-----------

[](#development)

Install dependencies:

```
## Contributing

1. Fork the repository
2. Clone your fork
3. Create your feature branch: `git checkout -b feature/YourFeature`
4. Commit your changes: `git commit -am 'Add new feature'`
5. Push to the branch: `git push origin feature/YourFeature`
6. Create a new Pull Request

### Guidelines

- Ensure test coverage for your changes.
- Follow PSR coding standards.
- Prefer small, focused pull requests.

```

Support
-------

[](#support)

If you encounter any issues, open an issue on [GitHub](https://github.com/zepekegno224/ObfuscateIdBundle/issues). For feature requests, please provide a detailed description of the use case and expected behavior.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance46

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~158 days

Total

2

Last Release

401d ago

PHP version history (2 changes)v1.0.0PHP &gt;=8.0

v1.1.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9a502394a6431a335e290b6f39ac90b09b44a46df5cd95ac3591e6bc09130b7b?d=identicon)[zepekegno224](/maintainers/zepekegno224)

---

Top Contributors

[![zepekegno224](https://avatars.githubusercontent.com/u/59239718?v=4)](https://github.com/zepekegno224 "zepekegno224 (11 commits)")

---

Tags

symfonybundleobfuscateidzepekegnooffusquer

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/zepekegno-obfuscate-id-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/zepekegno-obfuscate-id-bundle/health.svg)](https://phpackages.com/packages/zepekegno-obfuscate-id-bundle)
```

###  Alternatives

[rezzza/security-bundle

Signed requests check

1753.6k](/packages/rezzza-security-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
