I use this code via command line but I have the error call to a member function createRolle on null on line 14.
The command line is yii rbac/init as http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#access-control-filter
namespace app\commands;
use Yii;
use yii\console\Controller;
class RbacController extends Controller
{
public function actionInit()
{
$auth = Yii::$app->authManager;
$admin = $auth->createRole('admin');
$auth->add($admin);
$mod= $auth->createRole('moderator');
$auth->add($mod);
// Assign roles to users. 1 and 2 are IDs returned by IdentityInterface::getId()
// usually implemented in your User model.
// $auth->assign($author, 2);
// $auth->assign($admin, 1);
}
}