PHPackages                             jord-jd/thisishowirole - 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. jord-jd/thisishowirole

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

jord-jd/thisishowirole
======================

'This Is How I Role' is a PHP role management system that can be applied to any class.

v4.1.0(1mo ago)132LGPL-3.0-onlyPHPPHP &gt;=5.5.9CI passing

Since Jul 18Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/Jord-JD/ThisIsHowIRole)[ Packagist](https://packagist.org/packages/jord-jd/thisishowirole)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/jord-jd-thisishowirole/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (4)Versions (22)Used By (0)

This Is How I Role (TIHIR)
==========================

[](#this-is-how-i-role-tihir)

'This Is How I Role' is a PHP role management system that can be applied to any class.

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

[](#installation)

You can use `composer` to install this package. Just run `composer require jord-jd/thisishowirole`.

Setup
-----

[](#setup)

### Table creation

[](#table-creation)

First, create a new table in your application's database to store the TIHIR roles. You can use the following SQL snippet to create the table.

```
CREATE TABLE IF NOT EXISTS `tihir_roles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `class_name` varchar(1000) NOT NULL,
  `foreign_id` bigint(20) NOT NULL,
  `roles` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
```

Laravel applications receive the package migration automatically through package discovery. Run `php artisan migrate` as usual. The migration safely skips creation when an existing application migration has already created `tihir_roles`.

For Laravel versions without package discovery, add `JordJD\ThisIsHowIRole\ServiceProvider::class` to the application providers list.

### Database connection configuration

[](#database-connection-configuration)

If you're using Laravel, TIHIR will automatically use the database you've configured for your application, so you don't need to do anything here. We'll also use Eloquent to communicate with your database.

Otherwise, you need to set some environmental variables to point TIHIR towards your database. Something similar to the following will do the trick. If you're using a framework that supports it, you can put this in your `.env` file. If not, you can use PHP's built in `putenv` function.

```
TIHIR_DB_TYPE=mysql
TIHIR_DB_NAME=tihir_test
TIHIR_DB_HOST=192.168.1.44
TIHIR_DB_USER=tihir_test
TIHIR_DB_PASSWORD=PAMBSHcHssQqpw4A

```

Usage
-----

[](#usage)

This Is How I Role works by enhancing existing classes. This will work on any PHP class, be it a manually created class or a Laravel Eloquent model. The only requirement is that the class must have an accessible, numeric `id` property.

All you need to do is add two extra `use` lines to your class. This is shown in the example `User` class shown below.

```
require 'vendor/autoload.php';

use JordJD\ThisIsHowIRole\RolesTrait as Roles; // add('can_eat_cake');
$user->roles->add('can_eat_cookies');
$user->roles->remove('can_eat_cookies');

echo 'This user can ';

if ($user->roles->has('can_eat_cake')) {
  echo 'eat cakes... ';
}

if ($user->roles->has('can_eat_cookies')) {
  echo 'eat cookies... ';
}

echo "\n";
```

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance94

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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

Every ~182 days

Recently: every ~851 days

Total

21

Last Release

32d ago

Major Versions

v1.4.2 → v2.0.02017-03-12

v2.1.7 → v3.0.02026-02-14

v3.0.0 → v4.0.02026-02-14

PHP version history (2 changes)v1.0PHP &gt;=5.6.0

v1.4.2PHP &gt;=5.5.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (9 commits)")

---

Tags

phpphp-libraryrole-managerrolesphplibraryrolespermissions

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jord-jd-thisishowirole/health.svg)

```
[![Health](https://phpackages.com/badges/jord-jd-thisishowirole/health.svg)](https://phpackages.com/packages/jord-jd-thisishowirole)
```

###  Alternatives

[santigarcor/laratrust

This package provides a flexible way to add Role-based Permissions to Laravel

2.3k5.9M47](/packages/santigarcor-laratrust)[shanmuga/laravel-entrust

This package provides a flexible solution to add ACL to Laravel

68346.9k2](/packages/shanmuga-laravel-entrust)

PHPackages © 2026

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