yii 2 advancedテンプレートrabcのインストールと使用
1417 ワード
一、rabcコンポーネントをプロファイルに追加する
変更phpファイル、次のコードを追加します.
二、データテーブルの作成
1つ目の方法:コマンドライン方式(migration生成)で、ルートディレクトリに入り、コマンドを実行します.
2つ目の方法:vendoryisoftyii 2rbacmigrationsschema-mysqlを開く.sqlファイル、中のSQL文をコピーして、データベースに捨てて直接実行します;
最初に、テーブル接頭辞が必要な場合は、SQL文を手動で変更し、テーブル作成文にテーブル接頭辞を付ける必要があります.
続きは...
変更phpファイル、次のコードを追加します.
<?php
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 't_'
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
// rabc
'authManager' => [
'class' => 'yii\rbac\DbManager',
],
],
];
二、データテーブルの作成
1つ目の方法:コマンドライン方式(migration生成)で、ルートディレクトリに入り、コマンドを実行します.
./yii migrate --migrationPath=@yii/rbac/migrations
2つ目の方法:vendoryisoftyii 2rbacmigrationsschema-mysqlを開く.sqlファイル、中のSQL文をコピーして、データベースに捨てて直接実行します;
最初に、テーブル接頭辞が必要な場合は、SQL文を手動で変更し、テーブル作成文にテーブル接頭辞を付ける必要があります.
続きは...