vakata/user

A PHP user class

4.4.3 2024-08-06 12:37 UTC

README

Latest Version on Packagist Software License

A PHP user class.

Install

Via Composer

$ composer require vakata/user

Usage

use \vakata\database\DB;
use \vakata\user\UserManagementDatabase;
use \vakata\user\Group;
use \vakata\user\User;

$db = new DB('mysql://root@127.0.0.1/dbname');

$usrm = new UserManagementDatabase($db, [
    'tableUsers'             => 'users',
    'tableProviders'         => 'user_providers',
    'tableGroups'            => 'groups',
    'tablePermissions'       => 'permissions',
    'tableGroupsPermissions' => 'group_permissions',
    'tableUserGroups'        => 'user_groups'
]);

// get a user by ID
$user = $usrm->getUser(1);
// or by a provider
$user = $usrm->getUserByProviderID($provider, $providerID);

// add a group
$group = new Group(1, "Name", ["some", "permissions"]);
$usrm->saveGroup($group);
// add the new group to a user
$user->addGroup($group);
$usrm->saveUser($user);

Read more in the API docs

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email github@vakata.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.