Sunday, November 18, 2012

Howto Yii 1, a PHP framework

This framework seemed worth while to test out. Steps to get started is as follows;

Step 1: Install the framework.
From the site, follow the instructions for pre-requisite to install the Yii framework. Typically you will need

  1. Apache web browser
  2. PHP 5.1 and newer
  3. PHP PDO
  4. A database

Download Yii-1.1...tar.gz (in tar.gz format) from
Extract the tar.gz file to the web folder /var/www/html/yii1

It is also a good point to download the Yii-docs-1.1...tar.gz and extract it to follow its references and tutorials in PDF.

Step 2: Create the skeleton of a new web app.
At the prompt, access the framework's directory /var/www/html/yii1/framework

Type the following:
./yiic webapp ../testdrive

or in windows
yiic webapp ..\testdrive

Open a web browser and access the testdrive application

Step 3: Configure the timezone for the web app.
If an error on the timezone appears, complete following steps

vi /var/www/html/yii1/testdrive/protected/config/main.php

Just before the last line, add the timezone.


Access the testdrive application with the web browser, the error on timezone is gone. It does inform users the following;

You may change the content of this page by modifying the following two files:

View file: C:\Program Files\www\yii1\testdrive\protected\views\site\index.php
Layout file: C:\Program Files\www\yii1\testdrive\protected\views\layouts\main.php

Step 4. Understanding the structure
It is good to know the directories built for the testdrive web application under /var/www/html/yii1/testdrive. From here on, I will refer to the directory /var/www/html/yii1/testdrive as

/assets/  <=Empty
/css/  <=Contains 5 basic CSS files and a bg.gif file
/images/  <=Empty
/protected/  <=This is where your coding goes
/themes/  <=Several directories that is empty

Step 5. The database, mysql
Create a database named yii_testdrive, and load in the SQL from

By default it has the SQLLITE as its database, edit the file /config/main.php and comment out the following lines

'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

Uncomment the mysql lines below it and edit the database connection

'connectionString' => 'mysql:host=localhost;dbname=yii_testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',

Step 6. Generating the pages based on the database

Uncomment the GII web-based code generator and change the default password to MyPassword

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

Open a web browser and point to the gii resource

A login page appears, type the password as

You are then presented with the following to auto generate codes based on your database.

  1. Controller Generator
  2. Crud Generator
  3. Form Generator
  4. Model Generator
  5. Module Generator

Thats all for now...will continue when time permits.


smartsuite said...

I believe Web time sheet software makes the complete employee time clock tracking task easier. Its easy to update, approve and maintain the time sheets in no time.Time Attendance System

julian wood said...

Thanks for sharing information about yii framework. if you want to know more about it please view this
Yii framework Features and benefits

julian wood said...

Thanks for sharing information about yii framework. if you want to know more about it please view this
Yii framework Features and benefits

optisol biz said...

Very nice blog… I always enjoy to read your blog tech post… Very good writing skill.. I appreciated what you have done here… Good job! Keep posting.

If you like to learn about Yii 2.0 beta version, please visit this video:

Blog Archive