Before start the application login steps,
langkah-langkah memulai login aplikasi :
1. pertama koneksikan yii2 basic dengan database
2. buat tabel sesuai keinginan
3. menggunakan gii lakukan proses CRUD
4. merubah model user untuk mengaplikasikan IdentityInterfaceclass User
extends \yii\db\ActiveRecord menjadi \yii\web\IdentityInterface
5. kamu bisa mendefinisikan Model User menjadi userclass LoginForm
extends Model { public $username; public $password; public $email;
public $rememberMe = true;
mudah bukan....
yuuk langsung ikuti
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=phpbayar',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
// Schema cache options (for production environment)
//'enableSchemaCache' => true,
//'schemaCacheDuration' => 60,
//'schemaCache' => 'cache',
];
2. Membuat tabel user (user.sql)
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`first_name` varchar(250) NOT NULL,
`last_name` varchar(250) NOT NULL,
`phone_number` varchar(30) NOT NULL,
`username` varchar(250) NOT NULL,
`email` varchar(500) NOT NULL,
`password` varchar(250) NOT NULL,
`authKey` varchar(250) NOT NULL,
`password_reset_token` varchar(250) NOT NULL,
`user_image` varchar(500) NOT NULL,
`user_level` enum('Super Admin','Admin') NOT NULL DEFAULT 'Admin'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Jangan lupa input tabel user dulu sebelum mencoba login!!!!
Happy codingđź’†