PHP code example of memcrab / access

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();

- apt-get update
- apt-get install php-pear
- apt-get install php-dev
- apt-get install php-xml php7.0-xml
- apt-get install libyaml-dev
- pecl channel-update pecl.php.net
- pecl install yaml-2.0.0

- brew install php71 --with-pear
- brew install autoconf
- touch $(brew --prefix php71)/lib/php/.lock && chmod 0644 $(brew --prefix php71)/lib/php/.lock
- pecl install yaml-2.0.0