POSTED IN PHP YII

Yii2 Login authentication with REST api

Hello World…

Today we are going to discuss about Login authentication with REST api from yii2.

1. First let us Create a Module for user authentication in yii2 application. For this we first open the GII tool and generate Modules.
Module Class
backend\modules\api\Api
Module ID
api
Then click generate to generate module.

2. Then place the following code in
backend > config > main.php

3. Now create model and controller for that module. Make sure created models and controller are in
backend>modules>api.

4.Here, i just create a api for login auth. so create a function for login process r simply paste the code below

also make sure to include the use common\models\User in to of the page..

5. Thats it.. now trigger the url to check the response…
http://localhost/log-api/backend/web/index.php?r=api/orders/login

The result is false cause I just hit the url so it returns false.

Thats it guys….