enabel / permission-bundle
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
v1.0.2
2026-11-05 11:21 UTC
Requires
- php: >=8.4
- symfony/config: ^8.0
- symfony/dependency-injection: ^8.0
- symfony/http-kernel: ^8.0
- symfony/security-core: ^8.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.48
- phpunit/phpunit: ^13.0
- symfony/console: ^8.0
- symfony/css-selector: ^8.0
- symfony/dom-crawler: ^8.0
- symfony/framework-bundle: ^8.0
- symfony/phpunit-bridge: ^8.0
- symfony/security-bundle: ^8.0
- symfony/translation: ^8.0
- symfony/twig-bundle: ^8.0
- symfony/yaml: ^8.0
Suggests
- symfony/console: Required by the debug:permission command
- symfony/twig-bundle: Required to render the permission matrix with @EnabelPermission/matrix.html.twig
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-05 11:34:03 UTC
README
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.