Search by

enabel / permission-bundle

damienlagae

Permission enums for Symfony: roles, relations and rules declared on each case, one voter, a permission matrix

Package info

github.com/Enabel/permission-bundle

Type:symfony-bundle

pkg:composer/enabel/permission-bundle

Statistics

Installs: 201

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

v1.0.2 2026-11-05 11:21 UTC

This package is auto-updated.

Last update: 2026-11-05 11:34:03 UTC


README

CI

Permission enums for Symfony applications: who is granted each permission is declared on the enum case itself, one voter answers them all, and a matrix shows who can do what.

enum NewsPermissions: string implements Permission
{
    #[Grant('ROLE_NEWS_EDITOR')]
    case view = 'NEWS_VIEW';

    // An editor manages their own news, an admin all of them.
    #[Grant('ROLE_ADMIN')]
    #[Grant(relations: ['creator'])]
    case edit = 'NEWS_EDIT';

    // Every employee, but not the external staff.
    #[Grant('ROLE_EMPLOYEE', except: ['ROLE_EXTERNAL'])]
    case comment = 'NEWS_COMMENT';
}
#[IsGranted(NewsPermissions::edit->value, subject: 'news')]
{% if is_granted(enum('App\\Security\\Permissions\\NewsPermissions').edit, news) %}

Documentation

Read the documentation: the model, relations, rules, the permission matrix and the migration from an in-house permission map.

Installation

composer require enabel/permission-bundle

License

MIT License (MIT): see the License File for more details.