Download the PHP package artisanpack-ui/rbac without Composer

On this page you can find all versions of the php package artisanpack-ui/rbac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package rbac

ArtisanPack UI — RBAC

Role-based access control for Laravel: roles with hierarchy, permissions, Blade directives, middleware, and Gate integration.

This package is standalone — it does not depend on artisanpack-ui/security and can be used by any Laravel application or package (e.g. cms-framework) that needs roles and permissions without pulling in the full security suite.

Features

Installation

Run the package migrations:

(Optional) Publish the config file to override model bindings, table names, or cache settings:

Quick start

Add the traits to your User model:

Create a role + permission and assign them:

Models

Role

ArtisanPackUI\Rbac\Models\Role

Field Type Notes
name string unique
slug string unique; auto-derived from name via Str::slug() if not provided
description string|null
parent_id int|null foreign key to roles.id; set null on parent delete

Relationships:

Slug helpers: Role::findBySlug('editor'), Role::whereSlug('editor')->first(). hasRole('editor') and assignRole('editor') match against either name or slug.

Deleting a role detaches its permissions and nulls parent_id on its children.

Permission

ArtisanPackUI\Rbac\Models\Permission

Field Type Notes
name string unique
slug string unique; auto-derived from name via Str::slug() if not provided
description string|null

Relationships:

Slug helpers: Permission::findBySlug('pages.publish'), Permission::whereSlug('pages.publish')->first(). hasPermissionTo('pages.publish') and the Gate integration both match against either name or slug.

Deleting a permission detaches it from all roles.

Traits

HasRoles

Adds the roles() relationship plus assignment helpers.

assignRole and removeRole dispatch the rbac.user.role_assigned and rbac.user.role_removed events with the user and role.

HasPermissions

Resolves the user's effective permission set by walking the role hierarchy. Pair with HasRoles.

The trait caches the resolved permission collection per user. The cache TTL is configurable via artisanpack.rbac.cache.user_permissions_ttl.

Middleware

The service provider aliases permission to ArtisanPackUI\Rbac\Http\Middleware\CheckPermission. Apply it to routes that require one or more permissions — the user must hold at least one to proceed.

Unauthenticated requests abort with 401, authorized requests return 200, and authenticated requests without any of the listed permissions abort with 403.

Blade directives

Both directives render nothing for unauthenticated users.

@permission resolves through the user's effective permission set, which means it composes with role hierarchy. Use Laravel's built-in @can directive when you want the same check to flow through the Gate integration:

Gate integration

The service provider registers a Gate::before hook that resolves any ability matching a known permission slug through hasPermissionTo(). Standard Laravel authorization patterns work out of the box:

Abilities that don't correspond to an RBAC permission slug fall through to the normal Gate/Policy lookup, so policies you've defined elsewhere continue to work.

The list of known permission slugs is cached for artisanpack.rbac.cache.permission_names_ttl seconds. The cache is invalidated automatically when permissions are created, updated, or deleted.

Artisan commands

{user} accepts a numeric ID or any value that matches one of the configured user_lookup_fields (defaults to email). The assign/revoke commands are idempotent.

Configuration reference

Published to config/artisanpack/rbac.php.

Extending the base models

Other packages can extend Role and Permission and rebind them through config — useful when a downstream package needs extra relationships or scopes without forking this package. The cms-framework package uses this pattern for its Users module.

The Artisan commands, observers, traits, and migrations all read this config, so the substituted class is used everywhere.

Events

The service provider attaches observers that dispatch:

Pivot mutations are dispatched directly from the trait helpers since Laravel does not fire pivot events:

Listen for these in any application or sibling package — security-analytics uses them for audit logging.

Testing

Tests run against an in-memory SQLite database via Orchestra Testbench. The package's own test suite covers role / permission models, traits, middleware, Artisan commands, Blade directives, Gate integration, observers, and the configurable model-binding pattern.

Sibling packages

Package Scope
artisanpack-ui/security-full Meta-package — pulls in the full security suite (all six packages below) in a single require
artisanpack-ui/security Core: input sanitization, output escaping, KSES, CSP, security headers
artisanpack-ui/security-auth 2FA, password complexity, account lockout, sessions
artisanpack-ui/security-advanced-auth WebAuthn, SSO, social login, biometric, device fingerprinting
artisanpack-ui/secure-uploads File validation, malware scanning, signed-URL serving
artisanpack-ui/security-analytics Event logging, anomaly detection, SIEM, dashboards
artisanpack-ui/compliance GDPR / CCPA / LGPD consent, data subject rights, DPIA, retention, monitoring

Contributing

As an open source project, this package is open to contributions from anyone. Please read through the contributing guidelines to learn more about how you can contribute.


All versions of rbac with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
artisanpack-ui/core Version ^1.0
artisanpack-ui/hooks Version ^1.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package artisanpack-ui/rbac contains the following files

Loading the files please wait ...