UGRPM

What is UGRPM

UGRPM is a simple and easy to use PHP object oriented lirbary to manage (Users,Groups,Roles). This library use MySql database and PDO Object to connect. It's work with user as his id and don't care what the table you had made or its columns. You must have a database connection and pass it as PDO connection object to the UGRPM constructor. Built by Salam Aljehni (https://aljehni.com).

Main Idea

Suppose we have a PHP project, and there are users in it.
We may need to give some user the ability to do somethings and other users don't.
That means we want to give some users ability to run methods, methods belongs to classes, so we will give some users the ability to run method or not where methods have the form ClassNamespace@Method we will name this "role".
To give many users many roles it maybe hard or bored so we can use groups
User may be in many groups and groups may have many roles and on the other hand user himself may has many roles.
When any method run we can check if the user has permission to run it or not.
UGRPM give you all you need to do the above example, you can create roles and groups, give groups roles, give users roles, add users to groups, check user roles, get user groups, get groups roles, check group roles,..., and removing (user roles, group roles, user from groups ...).

Installation

1- Use composer to add UGRPM to your project.
composer require jsalam/ugrpm
2- In vendor/jsalam/ugrpm you will see sql directory contains tables.sql, import this file to your database.
3- To use UGRPM you must use UGRPM class:
use Jsalam\UGRPM\{UGRPM,Group,Role};
4- To create a new object of UGRPM use
$ugrpm = new UGRPM($connect);
Where $connect is your PDO connection object.
Now, for example, you can create a group in database like this:
$group = $ugrpm->createGroup(new Group(groupName:"Editors",description:"Editors Group"));
... and so on.

Feedback

Github link: https://github.com/salamj/ugrpm
Contact Me at: salamj[at]gmail.com

Credit

Author: Salam Aljehni (aljehni.com)
This library is published under license MIT License.