zakharov-andrew / yii2-user
Yii2 User
Installs: 406
Dependents: 2
Suggesters: 0
Security: 0
Stars: 5
Watchers: 4
Forks: 0
Open Issues: 1
Type:yii2-extension
Requires
- php: >=7.2
- dev-main
- v0.6.8
- v0.6.7
- v0.6.6
- v0.6.5
- v0.6.4
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.9
- v0.5.8
- v0.5.7
- v0.5.6
- v0.5.5
- v0.5.4
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.9
- v0.4.8
- v0.4.7
- v0.4.6
- v0.4.5
- v0.4.4
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.9
- v0.3.8
- v0.3.7
- v0.3.6
- v0.3.5
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.9
- v0.2.8
- v0.2.7
- v0.2.6
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.9
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
This package is auto-updated.
Last update: 2025-09-24 15:14:11 UTC
README
Yii2 user authentication module for management users and their rights.
- Registration, authorization, password recovery, change email and so on
- User administration interface
- Supports role creation
- Multiple user roles are supported
- Happy Birthday widgets
- Birthday Calendar widget
- logging of failed authorization attempts and blocking access via IP
- Supports languages: English, Russian
π Installation
The preferred way to install this extension is through composer.
Either run
$ composer require zakharov-andrew/yii2-user
or add
"zakharov-andrew/yii2-user": "*"
to the require
section of your composer.json
file.
Subsequently, run
./yii migrate/up --migrationPath=@vendor/zakharov-andrew/yii2-user/migrations
in order to create the settings table in your database.
Or add to console config
return [ // ... 'controllerMap' => [ // ... 'migrate' => [ 'class' => 'yii\console\controllers\MigrateController', 'migrationPath' => [ '@console/migrations', // Default migration folder '@vendor/zakharov-andrew/yii2-user/src/migrations' ] ] // ... ] // ... ];
π Usage
Add this to your main configuration's modules array
'modules' => [ 'user' => [ 'class' => 'ZakharovAndrew\user\Module', 'bootstrapVersion' => 5, // if use bootstrap 5 'showTitle' => true, // display H1 headings (default - true) 'enableUserSignup' => false, //Toggles user registration functionality (default - false) 'telegramToken' => '', // necessary for the bot to work 'telegramBotLink' => 'https://t.me/YOUR_BOT_NAME_FOR_USER_LINK', //change! // use for menu and access 'controllersAccessList' => [ 1001 => [ 'Users' => [ '/user/user/index' => 'users', '/user/user/create' => 'create user', ], ], 1002 => ['/user/roles/index' => 'Roles'] ], 'wallpapers' => [ [ 'url' => 'path/to/wallpaper1.jpg', 'roles' => ['user', 'admin'], // available to which roles ], [ 'url' => 'path/to/wallpaper2.jpg', 'roles' => ['admin'], // only for admin ], // ... ], ], // ... ],
Add this to your config\params.php
return [ // ... 'supportEmail' => 'change-this-email@test.com', // lifetime of the password reset token 'userResetPasswordTokenExpire' => 3600 // ... ];
If a pretty URL is enabled:
Add this to your main configuration's urlManager array
'urlManager' => [ //... 'rules' => [ 'login' => 'user/user/login', 'logout' => 'user/user/logout', 'profile' => 'user/user/profile', 'signup' => 'user/user/signup', 'wallpapers' => 'user/wallpaper/index', //... ], //... ],
π Happy Birthday widget
You can use the birthday greeting widget by customizing both the header and the message indicating that there are no birthdays today:
<?= \ZakharovAndrew\user\components\BirthdayWidget::widget([ 'headerMessage' => 'Todayβs birthdays:', 'noBirthdaysMessage' => 'Today, no one is celebrating a birthday.', // or empty 'useAvatars' => true ]); ?>
Widget for congratulating the user on his birthday:
<?= \ZakharovAndrew\user\components\BirthdayGreetingWidget::widget([ 'message' => '<h1>Happy Birthday, {username}!</h1>' ]) ?>
π Birthday Calendar Widget
Display a calendar of birthdays for the current week and next month:
<?= \ZakharovAndrew\user\widgets\BirthdayCalendarWidget::widget([ 'title' => 'Upcoming Birthdays', 'showAge' => true, 'maxUsersPerDay' => 3 ]); ?>
Options:
- title (string) - Calendar title
- showAge (bool) - Show user age (default: true)
- maxUsersPerDay (int) - Maximum number of users to show per day (default: 5)
Features:
- Shows birthdays from current week to next month
- π Weekly grouping with week numbers
- π― Current day highlighting
- π₯ Clickable user names linking to profiles
- π’ Age display with proper pluralization
- π± Responsive design for mobile devices
- π Multiple language support (English/Russian)
Advanced usage with custom parameters:
<?= \ZakharovAndrew\user\widgets\BirthdayCalendarWidget::widget([ 'title' => \ZakharovAndrew\user\Module::t('Upcoming Birthdays'), 'showAge' => true, 'maxUsersPerDay' => 5, 'view' => 'custom-calendar-view' // custom view file ]); ?>
π€ User Menu Widget
Add a user menu to your navigation bar with avatar, name and dropdown options:
Basic Usage
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <div class="container-fluid"> <a class="navbar-brand" href="#">Your App</a> <div class="collapse navbar-collapse"> <ul class="navbar-nav me-auto"> <!-- Your menu items --> </ul> <ul class="navbar-nav"> <?= \ZakharovAndrew\user\widgets\UserMenuWidget::widget() ?> </ul> </div> </div> </nav>
Custom Guest Content
Customize the display for non-authenticated users:
<?= \ZakharovAndrew\user\widgets\UserMenuWidget::widget([ 'guestContent' => ' <div class="d-flex gap-2"> <a href="' . \yii\helpers\Url::to(['/user/auth/login']) . '" class="btn btn-outline-light btn-sm"> ' . \ZakharovAndrew\user\Module::t('Login') . ' </a> <a href="' . \yii\helpers\Url::to(['/user/auth/signup']) . '" class="btn btn-primary btn-sm"> ' . \ZakharovAndrew\user\Module::t('Signup') . ' </a> </div> ', ]) ?>
Advanced Configuration
<?= \ZakharovAndrew\user\widgets\UserMenuWidget::widget([ 'guestView' => 'custom-guest-view', // custom view file 'guestContent' => [ 'loginUrl' => ['/user/auth/login'], 'signupUrl' => ['/user/auth/signup'], ], ]) ?>
π₯ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
π License
yii2-user it is available under a MIT License. Detailed information can be found in the LICENSE.md
.