PHP code example of imarc / auth

1. Go to this page and download the library: Download imarc/auth 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/ */

    

imarc / auth example snippets


$acl = new Auth\ACL();

$acl->allow('Admin', 'User', ['create', 'read', 'update', 'delete']);

$acl->alias('manage', ['create', 'read', 'update', 'delete']);

$acl->allow('Admin', 'Article', ['manage']);

$manager = new Auth\Manager($user);

$manager->add($acl)

$manager->is('Admin');

$manager->can('create', 'Article');

$manager->can('create', $article);

$manager->can('create', $article);

public function can(Manager $manager, $permission)
{
	if ($manager->has($permission, $this)) {
		return TRUE;
	}

	return $manager->entity == $this->getOwner();
}

php vendor/bin/phpstan -l7 analyse src/

php vendor/bin/phpunit --bootstrap vendor/autoload.php test/cases