PHP code example of jext / yii2-jrbac

1. Go to this page and download the library: Download jext/yii2-jrbac library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jext / yii2-jrbac example snippets


//example code
$menuItems = [
    //... your own menu items set
];
$jrbacMenu = \jext\jrbac\src\JMenu::getInstance()->getMenu();

//in adminLte theme template
echo dmstr\widgets\Menu::widget(
[
    'options' => ['class' => 'sidebar-menu'],
    'items' => array_merge($menuItems, $jrbacMenu),
]

//other default views

    NavBar::begin([
        'brandLabel' => Yii::t('app', Yii::$app->name),
        'brandUrl' => Yii::$app->homeUrl,
        'options' => [
            'class' => 'navbar-default',// navbar-fixed-top
        ],
    ]);

    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
        'items' => array_merge($menuItems, $jrbacMenu),
    ]);

    NavBar::end();
    
//to use this component, make sure you have assigned the right permissions to the logined user