Welcome – Yii Training



Welcome – Yii Training

0 0


yii-training-day-2

Yii Training Day 2

On Github shamsher31 / yii-training-day-2

Welcome

to

Yii Training

Prepared by

Shamsher Ansari

Day 2

Fundamentals
  • Entry script
  • Application
  • Components
  • Module
  • Conventions
Code Generations
  • GII tool
  • creating actions
  • creating access rules
  • creating models
  • creating views
  • creating forms

Entry script

Initially handles user Requests.

						
						// change the following paths if necessary
						$yii=dirname(__FILE__).'/../yiicore/framework/yii.php';
						$config=dirname(__FILE__).'/protected/config/main.php';

						// remove the following lines when in production mode
						defined('YII_DEBUG') or define('YII_DEBUG',true);

						// specify levels of call stack should be shown in each log message
						defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

						require_once($yii);
						Yii::createWebApplication($config)->run();
						
					
  • DEBUG Mode
  • PRODUCTION Mode

Application

Keeps Application Level Configurations ''front-controller''

Application Configuration.
  • protected/main/config.php
Application Base Directory.
  • protected folder
Application Components.
  • components array in config.php file
Core Application Components.
  • CDbConnection
  • CHttpRequest
  • CUrlManager
  • CErrorHandler

Components

Class, allows access to its properties and events.

Component Property
  • Public Member Variable
Component Event
  • Event Handler.
  • Starts with ''on''.
  • CEvent class.
  • Function with Parameters.

Module

Self-contained software unit includes MVC

						
							'modules'=>array(
								// uncomment the following to enable the Gii tool
								'gii'=>array(
									'class'=>'system.gii.GiiModule',
									'password'=>'gii',
									// If removed, Gii defaults to localhost only.
									'ipFilters'=>array('127.0.0.1','::1'),
								),
							),
						
					
Used in Large Scale Applications. Best example is Gii. User and Comment Management.

Conventions

Standards for writing application.

URL
  • http://hostname/index.php?r=ControllerID/ActionID
Code Configuration
  • Array of key-value Pair
Database
  • Table and columns in Lower case.
  • Separate words with name using underscore
  • Table name singular.
  • Table prefix eg: tbl_

GII tool

Web-based code generation tool.

						
							'modules'=>array(
								// uncomment the following to enable the Gii tool
								'gii'=>array(
									'class'=>'system.gii.GiiModule',
									'password'=>'gii',
									// If removed, Gii defaults to localhost only.
									'ipFilters'=>array('127.0.0.1','::1'),
								),
							),
						
					

Questions ?

Ask Google

"No one knows better then Google"

THANK YOU

Shamsher Ansari