/initial_yii

Primary LanguageCSSBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Step 1 Change directory to root directory of the project in terminal or command promopt
Step 2 Enter -:

php init

It will show like this -:

Yii Application Initialization Tool v1.0

Which environment do you want the application to be initialized in?

  [0] Development
  [1] Production

  Your choice [0-1, or "q" to quit]

Step 3 Enter 0
It will show like this -:

Initialize the application under 'Development' environment? [yes|no] 

Step 4 Enter yes
Step 5 go to root -> common -> config ->main-local.php
Config your database
DATABASE_NAME
DATABASE_USER_NAME
DATABASE_PASSWORD

<?php
return [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname="DATABASE_NAME',  
            'username' => 'DATABASE_USER_NAME',
            'password' => 'DATABASE_PASSWORD',
            'charset' => 'utf8',
        ],
        '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,
        ],
    ],
];

Step 6 Enter -:

composer install

Step 7 Enter -:

php yii migrate/up

If user table alreay exist it will show like this -:

Yii Migration Tool (based on Yii v2.0.39.3)

No new migrations found. Your system is up-to-date.

If not exist it wil show like this -:

Yii Migration Tool (based on Yii v2.0.39.3)

Creating migration history table "migration"...Done.
Total 2 new migrations to be applied:
    m130524_201442_init
    m190124_110200_add_verification_token_column_to_user_table

Apply the above migrations? (yes|no) [no]:

Enter yes
Roll back access controll
run this two commands in root directory

php yii migrate --migrationPath=@yii/rbac/migrations
php yii rbac/init

You can check database now extra table is created for roll back access control now if a new user login it will asign user role to new user
Step 8 Either run -:

composer require --prefer-dist yiisoft/yii2-authclient

or add

"yiisoft/yii2-authclient": "~2.2.0"

to the require section of your composer.json.
To activate email service go to common -> config ->main-local.php Replace mailer section by this-:

  'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
           'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'smtp.gmail.com',  
            'username' => 'YOUR_EMAIL',
            'password' => 'YOUR_PASSWORD',
            'port' => '587', 
            'encryption' => 'tls', 
        ],
            'useFileTransport' => false,
        ],

Important -: to send emails you have to enble less secure app on in your email privacy settings
Step 9 got to root -> frontend -> config -> main.php
now paste below code in main.php under component section

'authClientCollection' => [
        'class' => 'yii\authclient\Collection',
        'clients' => [
            'google' => [
                'class' => 'yii\authclient\clients\Google',
                'clientId' => 'xxxxxxxxxxxxxxxxxxxxxxxx',
                'clientSecret' => 'xxxxxxxxxxxxxxxxxxxxxx',
            ],
            'facebook' => [
                'class' => 'yii\authclient\clients\Facebook',
                'clientId' =>  'xxxxxxxxxxxxxxxxxxxxxxxxx',
                'clientSecret' =>  'xxxxxxxxxxxxxxxxxxxxxxxxx',
            ],
            'instagram' => [
                'class' => 'kotchuprik\authclient\Instagram',
                'clientId' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
                'clientSecret' => 'xxxxxxxxxxxxxxxxxxxxxxxxx',
            ],
            'linkedin' => [
                'class' => 'yii\authclient\clients\LinkedIn',
                'clientId' =>  'xxxxxxxxxxxxxxxxxxxxxxxxx',
                'clientSecret' =>  'xxxxxxxxxxxxxxxxxxxxxxxxx',
            ],
           'twitter' => [
                'class' => 'yii\authclient\clients\Twitter',
                'attributeParams' => [
                    'include_email' => 'true'
                ],
                'consumerKey' =>  'xxxxxxxxxxxxxxxxxxxxxxxxx',
                'consumerSecret' =>  'xxxxxxxxxxxxxxxxxxxxxxxxx',,
            ],
        ],

Then put your clientId and clientSecret
You will get keys in there devlope sites