1. Go to this page and download the library: Download memcrab/access 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/ */
memcrab / access example snippets
use memCrab\Exceptions\FileException;
use memCrab\File\Yaml;
use memCrab\Access\Access;
use memCrab\Exception\AccessException;
try {
$Yaml = new Yaml();
$rules = $Yaml->load("config/rules.yaml", null)->getContent();
$Access = new Access();
$Access->loadRules($rules);
if(!$Access->checkRights("post", "save", "admin")) throw AccessException("Access Denie.", 401);
// do all your work
}
catch(AccessException $error){
$Response = new \YourResponseClass();
$Response->setErrorResponse($error);
}
$Response->sendHeaders();
$Response->sendContent();