vima/core

Framework-agnostic RBAC + ABAC access control engine with pluggable storage backends and a built-in CLI.

Installs: 20

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 2

pkg:composer/vima/core

v0.1.5 2026-02-22 15:45 UTC

This package is auto-updated.

Last update: 2026-02-22 15:47:50 UTC


README

Vima Core is a framework-agnostic foundation for building robust Role-Based Access Control (RBAC) and Attribute-Based Access Control (ABAC) systems in PHP.

Unlike consumer-facing packages, Vima Core is designed specifically for framework developers and system architects. It provides a "Contract-First" toolkit that you can integrate into your framework's identity and storage systems.

๐ŸŽฏ Target Audience

  • Framework Integrators: Building bridges for Laravel, Tempest, CodeIgniter, etc.
  • Library Authors: Requiring a lightweight, testable authorization foundation.
  • Enterprise Architects: Designing custom, decoupled security architectures.

โœจ Core Features

  • ๐Ÿงฉ Contract-First Design: Decoupled from storage and framework specifics.
  • ๐Ÿ”‘ Entity Foundation: Standardized User, Role, and Permission entities.
  • ๐Ÿ“œ Unified Access Manager: A single entry point for both RBAC and ABAC checks.
  • โš™๏ธ Flexible Policies: Class-based and closure-based ABAC support.
  • ๐Ÿงช Testable: Designed with dependency injection and PSR-11 compliance.

๐Ÿ“ฆ Installation

composer require vima/core

๐Ÿ”ง Technical Overview

Vima Core provides the logic; you provide the implementation.

1. Register Implementation Contracts

As a framework integrator, you implement the storage interfaces (Repositories) and register them in the Vima container.

use Vima\Core\Contracts\RoleRepositoryInterface;
use Vima\Core\Contracts\PermissionRepositoryInterface;
use function Vima\Core\registerMany;

registerMany([
    RoleRepositoryInterface::class => new YourDatabaseRoleRepository(),
    PermissionRepositoryInterface::class => new YourDatabasePermissionRepository(),
    // ... other repositories
]);

2. Authorization Checks

Once set up, authorization is simple and consistent.

use Vima\Core\Services\AccessManager;
use function Vima\Core\resolve;

$vima = resolve(AccessManager::class);

// RBAC Check
if ($vima->can($user, 'posts.edit')) {
    // Authorized...
}

// ABAC Check (with context)
if ($vima->can($user, 'posts.edit', $post)) {
    // Authorized based on policy logic...
}

3. Defining Policies (ABAC)

Policies are class-based rules for specific resources.

use Vima\Core\Contracts\PolicyInterface;

class PostPolicy implements PolicyInterface {
    public function canEdit(User $user, Post $post) {
        return $user->id === $post->userId;
    }
}

$vima->registerPolicy(Post::class, PostPolicy::class);

๐Ÿ“š Documentation

Detailed guides for deep integration:

๐Ÿ“‚ Package Structure

src/
 โ”œโ”€โ”€ Contracts/         # Persistent layer and service interfaces
 โ”œโ”€โ”€ Entities/          # Core security data structures
 โ”œโ”€โ”€ Services/          # AccessManager, PolicyRegistry, and Managers
 โ”œโ”€โ”€ Support/           # Framework integration helpers
 โ””โ”€โ”€ DependencyContainer.php # Vima's PSR-11 container

๐Ÿ“œ License

This package is part of Vima PHP and is released under the MIT License.

(c) Vima PHP https://github.com/vimaphp