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

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

tomsgu/permission-bundle
========================

Provides a simple layer to store permissions.

1.0.0(4mo ago)021↓93.8%MITPHPPHP ^8.5CI passing

Since Mar 2Pushed 4mo agoCompare

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

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

[![Tests](https://github.com/Tomsgu/permission-bundle/actions/workflows/tests.yaml/badge.svg)](https://github.com/Tomsgu/permission-bundle/actions/workflows/tests.yaml)[![Static Analysis](https://github.com/Tomsgu/permission-bundle/actions/workflows/static-analysis.yaml/badge.svg)](https://github.com/Tomsgu/permission-bundle/actions/workflows/static-analysis.yaml)

Tomsgu Permission Bundle
========================

[](#tomsgu-permission-bundle)

A Symfony bundle that provides a simple permission layer for access control. Use it when you need something more flexible than roles but less complex than ACL.

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

[](#installation)

```
composer require tomsgu/permission-bundle
```

Register the bundle in `config/bundles.php`:

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

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

[](#configuration)

```
# config/packages/tomsgu_permission.yaml
tomsgu_permission:
    permissions:
        - { name: "EDIT_POST", description: "Can edit posts" }
        - { name: "DELETE_POST", description: "Can delete posts" }
    database:
        db_driver: orm
        permission_class: App\Entity\Permission
    cache: ~
```

### Create a Permission Entity

[](#create-a-permission-entity)

```
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Tomsgu\PermissionBundle\Entity\Permission as BasePermission;

#[ORM\Entity]
#[ORM\Table(name: 'permission')]
class Permission extends BasePermission
{
    #[ORM\Id]
    #[ORM\Column(type: 'integer')]
    #[ORM\GeneratedValue]
    protected int $id;

    public function getId(): int
    {
        return $this->id;
    }
}
```

### Implement UserPermissionInterface

[](#implement-userpermissioninterface)

Your `User` class must implement `UserPermissionInterface` to work with the `UserManager`:

```
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Tomsgu\PermissionBundle\Model\UserPermissionInterface;

#[ORM\Entity]
class User implements UserPermissionInterface
{
    #[ORM\ManyToMany(targetEntity: Permission::class)]
    #[ORM\JoinTable(name: 'users_permissions')]
    protected array $permissions;

    public function getId(): int
    {
        return $this->id;
    }

    public function getPermissions(): array
    {
        return $this->permissions;
    }
}
```

Usage
-----

[](#usage)

Inject `UserManagerInterface` to check permissions:

```
use Tomsgu\PermissionBundle\Model\UserManagerInterface;

class PostController
{
    public function __construct(private UserManagerInterface $userManager) {}

    public function edit(User $user): void
    {
        if ($this->userManager->hasPermission($user, 'EDIT_POST')) {
            // ...
        }
    }
}
```

### Loading Permissions

[](#loading-permissions)

Load permissions defined in your configuration into the database:

```
php bin/console tomsgu:permission:load
```

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance77

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

125d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2694769?v=4)[Tomsgu](/maintainers/Tomsgu)[@Tomsgu](https://github.com/Tomsgu)

---

Top Contributors

[![Tomsgu](https://avatars.githubusercontent.com/u/2694769?v=4)](https://github.com/Tomsgu "Tomsgu (3 commits)")

---

Tags

symfonybundlesecurityauthorizationpermission

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tomsgu-permission-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tomsgu-permission-bundle/health.svg)](https://phpackages.com/packages/tomsgu-permission-bundle)
```

PHPackages © 2026

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