1. Go to this page and download the library: Download renoki-co/acl 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/ */
renoki-co / acl example snippets
use RenokiCo\Acl\Concerns\HasPolicies;
use RenokiCo\Acl\Contracts\RuledByPolicies;
class Account implements RuledByPolicies
{
use HasPolicies;
public $id;
/**
* Resolve the account ID of the current actor.
* This value will be used in ARNs for ARNable static instances,
* to see if the current actor can perform ID-agnostic resource actions.
*
* @return null|string|int
*/
public function resolveArnAccountId()
{
return $this->id;
}
/**
* Resolve the region of the current actor.
* This value will be used in ARNs for ARNable static instances,
* to see if the current actor can perform ID-agnostic resource actions.
*
* @return null|string|int
*/
public function resolveArnRegion()
{
return $_GET['region'] ?? 'local';
}
}
use RenokiCo\Acl\Concerns\HasArn;
use RenokiCo\Acl\Contracts\Arnable;
use RenokiCo\Acl\BuildResourceArn;
class Server implements Arnable
{
use HasArn;
public string $id;
public string $accountId;
public string $name;
public string $ip;
public function arnResourceAccountId()
{
return $this->accountId;
}
public function arnResourceId()
{
return $this->id;
}
}
use RenokiCo\Acl\Concerns\HasPolicies;
use RenokiCo\Acl\Contracts\RuledByPolicies;
class Account implements RuledByPolicies
{
use HasPolicies;
public $id;
public $teamId;
public function resolveArnAccountId()
{
return $this->teamId;
}
}
use RenokiCo\Acl\Concerns\HasArn;
use RenokiCo\Acl\Contracts\Arnable;
use RenokiCo\Acl\BuildResourceArn;
class DemoServer implements Arnable
{
use HasArn;
public static function arnResourceType()
{
return 'server';
}
}
class Server implements Arnable
{
use HasArn;
public function arnResourcePartition()
{
return 'php';
}
public function arnResourceService()
{
return 'baremetal';
}
public function arnResourceRegion()
{
return $this->region;
}
}