這篇文章給大家分享的是有關(guān)yii2使用user組件的示例的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
從網(wǎng)站建設(shè)到定制行業(yè)解決方案,為提供成都網(wǎng)站建設(shè)、成都網(wǎng)站制作服務(wù)體系,各種行業(yè)企業(yè)客戶提供網(wǎng)站建設(shè)解決方案,助力業(yè)務(wù)快速發(fā)展。創(chuàng)新互聯(lián)建站將不斷加快創(chuàng)新步伐,提供優(yōu)質(zhì)的建站服務(wù)。yii2怎么使用user組件
1、首先安裝yii2 user組件
composer require "dektrium/yii2-user:0.9.*@dev"
2、然后進(jìn)行配置
'modules' => [ 'user' => [ 'class' => 'dektrium\user\Module', 'confirmWithin' => 21600, 'cost' => 12, 'admins' => ['admin'] ], ],
3、注意事項(xiàng)
(相關(guān)教程推薦:yii框架)
同時(shí)刪除本來(lái)的user配置
此外要注意自己寫的控制器,model,數(shù)據(jù)庫(kù)這些都不能有user
最后執(zhí)行$ php yii migrate/up --migrationPath=@vendor/dektrium/yii2-user/migrations
這樣就安裝完畢。
4. 使用yii2-user
下面是對(duì)應(yīng)功能的url,其余使用和yii2自帶的user差不多的
/user/registration/register Displays registration form /user/registration/resend Displays resend form /user/registration/confirm Confirms a user (requires id and token query params) /user/security/login Displays login form /user/security/logout Logs the user out (available only via POST method) /user/recovery/request Displays recovery request form /user/recovery/reset Displays password reset form (requires id and token query params) /user/settings/profile Displays profile settings form /user/settings/account Displays account settings form (email, username, password) /user/settings/networks Displays social network accounts settings page /user/profile/show Displays user's profile (requires id query param) /user/admin/index Displays user management interface
例如:
user->isGuest){ ?> = Html::a(" 注 冊(cè)",['/user/registration/register']); ?> | = Html::a(" 登 錄",['/user/security/login']); ?> = Html::a(" 退出",['/user/security/logout']); ?>
感謝各位的閱讀!關(guān)于“yii2使用user組件的示例”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!