PHPackages                             ray/role-module - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ray/role-module

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ray/role-module
===============

Role Module for Ray.Di

1.0.0(4y ago)4146.4k↓13.3%22MITPHPPHP ^7.3 || ^8.0

Since Jul 22Pushed 2y ago8 watchersCompare

[ Source](https://github.com/ray-di/Ray.RoleModule)[ Packagist](https://packagist.org/packages/ray/role-module)[ RSS](/packages/ray-role-module/feed)WikiDiscussions 0.x Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (2)

Ray.RoleModule
==============

[](#rayrolemodule)

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

[](#installation)

### Composer install

[](#composer-install)

```
$ composer require ray/role-module

```

### Module install

[](#module-install)

You need to provide `RoleProvider`.

```
class AppRoleProvider implements RoleProviderInterface
{
    public function get()
    {
        return 'admin';
    }
}
```

Install module with `RoleProvider`.

```
use Ray\RoleModule\ZendAclModule;
use Ray\Di\AbstractModule;
use Laminas\Permissions\Acl\Role\GenericRole;
use Laminas\Permissions\Acl\Acl;

class AppModule extends AbstractModule
{
    protected function configure()
    {
        // @see http://framework.zend.com/manual/current/en/modules/zend.permissions.acl.intro.html
        $acl = new Acl();
        $roleGuest = new GenericRole('guest');
        $acl->addRole($roleGuest);
        $acl->addRole(new GenericRole('staff'), $roleGuest);
        $acl->addRole(new GenericRole('editor'), 'staff');
        $acl->addRole(new GenericRole('administrator'));
        $this->install(new ZendAclModule($acl, AppRoleProvider::class));
    }
}
```

### Usage

[](#usage)

Simple usage:

```
use Ray\RoleModule\Annotation\RequiresRoles;

#[RequiresRoles(['admin'])]
class Foo
{
    public function createUser($id)
    {
```

You can annotate individual method too, It has priority over class attribute.

```
use Ray\RoleModule\Annotation\RequiresRoles;

class Foo
{

    #[RequiresRoles(['admin', 'editor'])]
    public function createUser($id)
    {
```

### Demo

[](#demo)

```
$ php demo/run.php
// It works!
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 83.7% 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

Every ~1542 days

Total

3

Last Release

868d ago

Major Versions

0.1.0 → 1.0.02022-04-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/db4fc75ffc631168d0d7143b6f2c24b1534dfb921212bd851c026c5cbbb1344d?d=identicon)[koriym](/maintainers/koriym)

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (36 commits)")[![jingu](https://avatars.githubusercontent.com/u/892913?v=4)](https://github.com/jingu "jingu (7 commits)")

---

Tags

aclray-modulezend-permission

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ray-role-module/health.svg)

```
[![Health](https://phpackages.com/badges/ray-role-module/health.svg)](https://phpackages.com/packages/ray-role-module)
```

###  Alternatives

[honeybee/honeybee

Library for implementing CQRS driven, event-sourced and distributed architectures.

222.1k4](/packages/honeybee-honeybee)

PHPackages © 2026

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