PHPackages                             loremipsum/permission-checker-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. loremipsum/permission-checker-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

loremipsum/permission-checker-bundle
====================================

Symfony bundle to handle authorization, i.e. check permission to perform action on a resource.

v0.4.1(6mo ago)2168MITPHPPHP &gt;=7.1

Since Oct 2Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/loremipsum/permission-checker-bundle)[ Packagist](https://packagist.org/packages/loremipsum/permission-checker-bundle)[ Docs](https://www.loremipsum.at)[ RSS](/packages/loremipsum-permission-checker-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (13)Used By (0)

PermissionChecker bundle
========================

[](#permissionchecker-bundle)

Symfony bundle to handle authorization, i.e. check permission to perform action on a resource. This bundle is similar to the symfony voter but uses permission objects.

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

[](#configuration)

```
# config/packages/lorem_ipsum_permission_checker.yaml

lorem_ipsum_permission_checker:
    roles:
        admin: ROLE_ADMIN
        super_admin: ROLE_SUPER_ADMIN
    default_permission: \App\Security\Permission\AppPermission
```

`default_permission` is used by `hasActionPermission` twig function.

Permission example
------------------

[](#permission-example)

Usage example:
Check if the current user has permission to update an existing user. Call `mustHave` or `has`on the `PermissionChecker` instance with the `UserPermission`. `mustHave` throws an exception if the permission is not granted, whereas `has` just returns a boolean.

```
/** @var LoremIpsum\PermissionCheckerBundle\PermissionChecker $permissionChecker **/
$permissionChecker->mustHave(new UserPermission(UserPermission::UPDATE, $user));
```

`AppPermission` example:

```
