1. Go to this page and download the library: Download lanlin/god library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lanlin / god example snippets
use God\God;
$God = new God('path/to/model.conf', 'path/to/policy.csv');
$God->allows('you', 'evil book', 'read'); // Does God allows you to do this?
new God();
new God(string $modelPath);
new God(string $modelPath, string $policyFile);
new God(string $modelPath, Adapter $adapter);
new God(Model $model);
new God(Model $model, Adapter $adapter);
// demo for mysql
$dbHost = "127.0.0.1";
$dbPort = 3306;
$dbName = "your_database_name";
$username = "root";
$password = "your_password";
// php mysql pdo demo
$pdo = new \PDO("mysql:host={$dbHost};port={$dbPort};dbname={$dbName}", $username, $password);
// init god model with csv
$g = new God('tests/Examples/rbac_model.conf', 'tests/Examples/rbac_policy.csv');
$m = $g->getModel();
// save policy to database
$a = new Adapter($pdo);
$a->savePolicy($m);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.