Download the PHP package divineomega/thisishowirole without Composer
On this page you can find all versions of the php package divineomega/thisishowirole. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download divineomega/thisishowirole
More information about divineomega/thisishowirole
Files in divineomega/thisishowirole
Package thisishowirole
Short Description 'This Is How I Role' is a PHP role management system that can be applied to any class.
License LGPL-3.0-only
Informations about the package thisishowirole
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
You can use composer to install this package.
Just run composer require jord-jd/thisishowirole.
Setup
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.
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
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.
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.
This User class now has the TIHIR roles system available to it. You can now
use various methods to add, remove or check for roles against this class. The
snippet below shows how roles can be manipulated.