PHPackages                             sybio/permission-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. sybio/permission-bundle

ActiveLibrary[Security](/categories/security)

sybio/permission-bundle
=======================

A Symfony bundle to manage permissions as Value Objects.

v1.1.0(2mo ago)2310↓100%MITPHPPHP &gt;=8.3CI passing

Since Dec 19Pushed 2mo agoCompare

[ Source](https://github.com/Sybio/permission-bundle)[ Packagist](https://packagist.org/packages/sybio/permission-bundle)[ Docs](https://github.com/Sybio/permission-bundle)[ RSS](/packages/sybio-permission-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (9)Versions (4)Used By (0)

Permission Bundle
=================

[](#permission-bundle)

A Symfony bundle to manage permissions (authorizations) as Value Objects, with an integrated validation system and native integration with Symfony's security system.

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

[](#introduction)

This bundle provides a modern and type-safe approach to managing permissions in your Symfony applications. Instead of using strings or constants, permissions are represented as immutable **Value Objects**, each having its own **checker** (equivalent to a handler) that contains the business logic for validation.

This approach offers better maintainability, better testability, and better IDE integration thanks to strong typing.

Advantages
----------

[](#advantages)

✅ **Type-safe** : Permissions are typed objects, not strings
✅ **Separation of concerns** : Each permission has its own dedicated checker
✅ **Symfony integration** : Compatible with the security (Voter) and validation systems
✅ **Auto-configuration** : Checkers are automatically detected and registered
✅ **Testability** : Easy to test thanks to dependency injection
✅ **Maintainability** : Easy to extend with new permissions and maintain over time

Installation
------------

[](#installation)

```
composer require sybio/permission-bundle
```

If you're using Symfony Flex, the bundle will be automatically registered. Otherwise, register it manually in `config/bundles.php`:

```
return [
    // ...
    Sybio\PermissionBundle\SybioPermissionBundle::class => ['all' => true],
];
```

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

[](#configuration)

Configuration is optional. By default, the bundle uses the `PERMISSION` security attribute. You can customize it in `config/packages/sybio_permission.yaml`:

```
sybio_permission:
    security_attribute: 'PERMISSION'  # Attribute used by the PermissionVoter
```

Creating a permission and its checker
-------------------------------------

[](#creating-a-permission-and-its-checker)

### 1. Create the permission (Value Object)

[](#1-create-the-permission-value-object)

Create a class that implements `PermissionInterface`:

```
