2017 © Pedro Peláez
 

library permissions

image

midnight/permissions

  • Friday, March 17, 2017
  • by MidnightDesign
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,391 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 44 % Grown

The README.md

Check Build, (*1)

midnight/permissions

ACL and RBAC weren't the permission models I was looking for. So I wrote my own., (*2)

Installation

Install midnight/permissions via Composer., (*3)

Usage

You need a Container that can provide your PermissionService with permissions. In this example, we're going to use league/container, but any container implementing Psr\Container\ContainerInterface will work., (*4)

For brevity, the user and resource are arrays in this example. Most likely, they will be objects any real-world project., (*5)

class CanDoSomething implements Midnight\Permissions\PermissionInterface
{
    public function isAllowed($user = null, $resource = null): bool {
        return $user === $resource['owner'];
    }
}

$container = new League\Container\Container();
$container->add('can_do_something', CanDoSomething::class);

$permissionService = new Midnight\Permissions\PermissionService($container);

$permissionService->isAllowed('Rudolph', 'can_do_something', ['owner' => 'Rudolph']); // true
$permissionService->isAllowed('Rudolph', 'can_do_something', ['owner' => 'Christoph']); // false

Laminas Module

There's also a Laminas module that will let you access the PermissionService via the Service Manager, add permissions via the config and give you view helpers and controller plugins. It's called midnight/permissions-module., (*6)

The Versions

17/03 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

permissions permission access control

17/03 2017

1.1.1

1.1.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

permissions permission access control

17/03 2017

1.1.0

1.1.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

permissions permission access control

23/10 2015

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

permissions permission access control