Download the PHP package deadmantfa/yii2-rbac without Composer
On this page you can find all versions of the php package deadmantfa/yii2-rbac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download deadmantfa/yii2-rbac
More information about deadmantfa/yii2-rbac
Files in deadmantfa/yii2-rbac
Package yii2-rbac
Short Description Yii2 RBAC Module, updated for PHP 8 and above
License BSD-3-Clause
Informations about the package yii2-rbac
Yii 2 JustCoded RBAC Extension (Forked)
This is a fork of the Yii 2 RBAC extension by JustCoded. It extends the RBAC Manager with a route-based access control system, offering additional features and compatibility with modern PHP versions.
Features
Pre-defined Roles and Permissions
The extension provides the following pre-defined roles and permissions:
Permissions:
- *`` (master permission)**: A parent permission for all other permissions.
administer
: Permission to check access to the admin panel.
Roles:
Guest
: Not authenticated users.Authenticated
: Authenticated users (add this to your users manually).Administrator
: Users withadminister
permission, granting access to the admin panel.Master
: Superuser role with access to everything via*
permission.
Routes Scanner
The extension includes a feature to scan your project files and automatically import permissions for:
- Controller-wide permissions:
{controller->uniqueId}/*
- Action-specific permissions:
{controller->uniqueId}/{action->id}
You can create or assign roles and permissions to configure your application's high-level access control.
Route Access Filter
Easily restrict access to specific parts of your site based on roles or permissions. The extension provides a filter
similar to Yii's AccessControl
, enabling route-based permissions checks. If access is denied, a 403 Forbidden
error
is triggered.
GUI for Managing Roles and Permissions
A simple GUI is included to manage roles and permissions directly from the application.
Note: The GUI is in alpha. Avoid sharing access to this interface with end-users.
Installation
Install the extension via Composer:
Alternatively, add the following to your composer.json
:
Configuration
Component Setup
Add the RBAC module and authManager
configuration in your application:
Bootstrap 4 Themes Support
By default, the views use Bootstrap 3 via yii2-bootstrap
. For Bootstrap 4 support, update the container configuration:
Note: Add
yiisoft/yii2-bootstrap4
to yourcomposer.json
.
Basic RBAC Configuration
Follow the official Yii 2 RBAC documentation to configure RBAC storage (e.g., create necessary files or database tables).
For DbManager
, initialize the database tables with the following migration command:
Initialize Base Roles
Run the following commands to set up default roles and permissions:
For Advanced Template:
For Basic Template:
Usage
GUI Interface
Access the RBAC GUI by navigating to the module's configured route. Use the GUI to manage roles and permissions.
Note: The role-permission selector is a temporary solution and may not display a proper tree structure. This will be addressed in future updates.
Route Access Filter
Use the RouteAccessControl
filter to enforce route-based access control. The filter checks permissions during each
request and throws a 403 Forbidden
error for unauthorized routes.
Per Controller
Globally
Example Project
You can see an example of this RBAC extension in action in the Yii2 Starter Kit.
All versions of yii2-rbac with dependencies
yiisoft/yii2 Version ^2.0.51
kartik-v/yii2-widget-select2 Version ^2.2.0
yiisoft/yii2-bootstrap4 Version ^2.0