germania-kg / permissions
2.1.5
2022-03-30 10:14 UTC
Requires
- php: ^5.6|^7.0
- psr/container: ^1.0
- psr/log: ^1.0
Requires (Dev)
- monolog/monolog: ^1.16
- php-coveralls/php-coveralls: ^2.0
- phpunit/dbunit: ^2.0|^3.0
- phpunit/phpunit: ^5.7|^6.0
README
Installation
$ composer require germania-kg/permissions
MySQL users may install the tables permissions and permissions_roles using install.sql.txt
in sql/
directory.
Usage
<?php use Germania\Permissions\PermissionsAcl; // Have your PDO and optional a PSR-3 Logger at hand $pdo = new PDO; $logger = new Monolog; // Pass PDO and table names, // optionally with PSR-3 Logger $perms = new PermissionsAcl( $pdo, "permissions", "permissions_roles" ); $perms = new PermissionsAcl( $pdo, "permissions", "permissions_roles", $logger ); // Use Callable $acl = $perms();
print_r( $acl ); // Keys are permissions; // Element arrays are roles ( [bar] => Array ( [0] => 1 ) [foo] => Array ( [0] => 1 [1] => 2 ) [quc] => Array ( ) )
Development
$ git clone https://github.com/GermaniaKG/Permissions.git
$ cd Permissions
$ composer install
Setup MySQL tables permissions and permissions_roles as in sql/install.sql.txt
.
Unit tests
Either copy phpunit.xml.dist
to phpunit.xml
and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:
$ composer test # or $ vendor/bin/phpunit
In phpunit.xml
, edit the database credentials:
<php> <var name="DB_DSN" value="mysql:host=localhost;dbname=test;charset=utf8" /> <var name="DB_USER" value="root" /> <var name="DB_PASSWD" value="" /> <var name="DB_DBNAME" value="test" /> <var name="DB_SETUP" value="sql/install.sql.txt" /> </php>
Go to project root and issue phpunit
.