yii create application

Hi,

this is the steps to create web app in yii application.

open terminal:

create one database in phpmyadmin name:mydb;

table:user: uid,uname,password,

  1. go thru this path cd/var/www

  2. yii\framework\yiic webapp\ myappdemo

  3. yes

  4. your application is created.

  5. open protected/ config/main.php

    open it and set

  6. now




              // uncomment the following to enable the Gii tool

		/*

		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'Enter Your Password Here',

		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

		),

		*/

  

type password for further creation of model & CRUD Generate.

in main .php file





                // uncomment the following to use a MySQL database

		/*

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=testdrive',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '',

			'charset' => 'utf8',

		),

		*/



in above set your database name ,username,password for database connectivity.

8) open componenet/useridentity.php file and set this below function

table

in componenet /UserIdentity.php file




public function authenticate()

	{

		

		$model=Users::model()->findByAttributes(array('userid'=>$this->username));

		    if($model != NULL)

		    {

		        if($model->password==MD5($this->password))

		          $this->errorCode=self::ERROR_NONE;

		        else

		         $this->errorCode=self::ERROR_PASSWORD_INVALID;

		    }

		    else

		    {

		        $this->errorCode=self::ERROR_USERNAME_INVALID;

		    }       


		return !$this->errorCode;		

		

		/*

		$users=array(

			// username => password

			'demo'=>'demo',

			'admin'=>'admin',

		);

		if(!isset($users[$this->username]))

			$this->errorCode=self::ERROR_USERNAME_INVALID;

		elseif($users[$this->username]!==$this->password)

			$this->errorCode=self::ERROR_PASSWORD_INVALID;

		else

			$this->errorCode=self::ERROR_NONE;

		return !$this->errorCode;

		*/

	}



now login with your database is done.

  1. array(‘label’=>‘User’,‘url’=>array(‘users/admin’)), put this link on views/layout/main.php file. for menu link.