PHPackages                             leitom/role - 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. leitom/role

AbandonedLibrary[Authentication &amp; Authorization](/categories/authentication)

leitom/role
===========

A easy but higly scaleable role manager for laravel 4.1

324[1 issues](https://github.com/leitom/role/issues)PHP

Since Jan 25Pushed 12y ago1 watchersCompare

[ Source](https://github.com/leitom/role)[ Packagist](https://packagist.org/packages/leitom/role)[ RSS](/packages/leitom-role/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Easy but scalable role manager for laravel 4.1
==============================================

[](#easy-but-scalable-role-manager-for-laravel-41)

This package makes it very easy to add role capabilities to laravel 4.1 It uses routes as access points. That means that all routes are synced to a persisant storage(default: database) and then routes connect to different roles that can be connected to users etc. This package does not handle any controllers/logic for creating or maintaining roles and users. But it comes with two eloquent models used for persisant storage(Role and Route) that you can connect to your user model. The logic that handles queries uses the database/query builder.

The package integrates with laravel auth right out of the box.

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

[](#installation)

Begin by installing this package through Composer. Edit your project's `composer.json` file to require `leitom/role`

```
"require": {
	"laravel/framework": "4.1.*",
	"leitom/role": "1.0.*@dev"
},
"minimum-stability": "dev"

```

Next, update composer from the Terminal: `composer update`

Once this operation completes, the final step is to add the service provider. Open `app/config/app.php`, and add a new item to the provider array. `'Leitom\Role\RoleServiceProvider'`

Setup
-----

[](#setup)

#### Migrations and Configs

[](#migrations-and-configs)

The package provides an artisan command for doing all this by it's self just type `php artisan role:install`NB: This package is a work in progress, if you find problems with using the installer use the file located in `src/migrations/structure.mysql` to get the table structure.

Or you can check out:  on how to publish the packages migrations and config files.

#### Seed

[](#seed)

Generate a seed file to populate the super admin role with id 1, it will lokk something like this:

```
class RolesTableSeeder extends Seeder
{
	public function run()
	{
		$role = new Leitom\Role\Eloquent\Role;
		$role->name = 'Super admin';
		$role->description = 'A super admin has access to all routes';
		$role->save();
	}
}
```

#### Add filter

[](#add-filter)

Add the filter with the name from config `role.control.identifier` to your route/group

#### Integrating with your eloquent auth model

[](#integrating-with-your-eloquent-auth-model)

Add the following line to your auth model default it's: `app/models/User.php`

```
public function roles()
{
	return $this->belongsToMany('Leitom\Role\Eloquent\Role', 'user_role');
}
```

Usage
-----

[](#usage)

#### Sync routes

[](#sync-routes)

The package comes with an artisan command for automatic syncing the routes to persisant storage it also comes with an option in config `super.admin.sync` for syncing all new routes to an super admin role identified by option `super.admin.id` in config.

Run the following command each time you add a new route to your application: `php artisan routes:sync` this will update all routes to the db table and clear the laravel cache.

### Access check functions

[](#access-check-functions)

Check if the current logged in user has access to a url `Role::hasUrlAccess($method, $url, $host = '')`

Check if the current logged in user has access to a route `Role::hasRouteAccess($method, $route, $host = '')`

Check if the current logged in user has access to a action `hasActionAccess($method, $action, $host = '')`

### Access level

[](#access-level)

In your views you can use `Role::accessLevel()` to check for additional access level. That means if the user have access to the current route/uri but to see a part of the page the access level have to be larger than 4:

```
if (Role::accessLevel() > 4) {
	echo "Level 5 acceess granted.";
}
```

### Laravel extensions

[](#laravel-extensions)

The package have extended the HtmlBuilder and the FormBuilder. This allows us to check for role access on forms and when generating links.

When using `HTML::linkRoute()` then the package check's if the current logged in user have access to the route if not the link dont show. same for `HTML::linkAction()`The package includes an function `HTML::roleCheckLink()` wich are the same as `HTML::link()` except that the third parameter accepts an array of parameters like `HTML::linkRoute() and HTML::linkAction()` does.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/29a951c4d5299e1375ea57b5d0174981352c2664df175cb4a074a3c0f87128a0?d=identicon)[leitom](/maintainers/leitom)

---

Top Contributors

[![leitom](https://avatars.githubusercontent.com/u/222862?v=4)](https://github.com/leitom "leitom (31 commits)")

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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