Follow this guide to install and configure the ddmtechdev/rbac module in your Yii2 application.
Run the following command to install the RBAC module via Composer:
php composer require ddmtechdev/rbac:@dev
Apply the necessary database migrations:
php yii migrate/up --migrationPath=@vendor/ddmtechdev/rbac/migrations
Modify your common/config/main.php
file and add the following inside the modules
array:
'modules' => [
'rbac' => [
'class' => 'ddmtechdev\rbac\Module',
],
...
],
Modify your console/config/main.php
file and add the following inside the controllerMap
array:
'controllerMap' => [
'rbac-seeder' => [
'class' => 'ddmtechdev\rbac\console\RbacSeeder',
],
...
],
To ensure proper loading of the module, open composer.json
and update it as follows:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/ddmtechdev/rbac.git"
}
...
]
"autoload": {
"psr-4": {
"ddmtechdev\\rbac\\": ""
}
...
},
- 🔹 Flush cache (to apply changes):
- 🔹 Run RBAC seeder (to initialize roles & permissions):
- 🔹 Restart the web server (if necessary)
- 🔹 Access the RBAC module via your configured routes
php yii cache/flush-all
php yii rbac-seeder/init
If you encounter any issues, check the logs or verify that dependencies are correctly installed. 🚀