William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

Install Yii without a Database

Install Yii without a Database

Yii is a high-performance PHP framework best for developing Web 2.0 applications. It comes out late, but rises very quickly. By now, it already ranks among top of PHP frameworks.

Yii comes with rich features: MVC, DAO/ActiveRecord, I18N/L10N, caching, authentication and role-based access control, scaffolding, testing, etc. It can reduce development time significantly, thus worth a try and integrate into my existing web systems.

Recently I download and setup Yii in my notebook. Compared to Magento, it is much easier to setup with the help of wonderful installation document. The followin is my steps after download Yii and extract it in C:\php_app directory.

(1) In Apache’s httpd.conf file add an alias entry:

Alias 'yii' 'c:\php_app\yii\'

Restart Apache server to active the modification.
(2) To check the installation environment reaches the Yii requirements, running:

http://localhost/yii/requirements/

(3) Like traditional framework’s generator, using the following command to generate MVC application ‘testdrive’ which is an application of Yii.

cd c:\php_app\yii\framework
yiic webapp ..\testdrive

The new Yii application will be created at “c:/php_app/Yii/testdrive/”.
(4)You can now access it by the following URL:

http://localhost/yii/testdrive/index.php

(5) For the menu (php file) which shows on the home page, the concept here are intuitively and clearly:

<?php $this->widget('zii.widgets.CMenu',array(
 'items'=>array(
  array('label'=>'Home', 'url'=>array('/site/index')),
  array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
  array('label'=>'Contact', 'url'=>array('/site/contact')),
  array('label'=>'Login', 'url'=>array('/site/login'), 
   'visible'=>Yii::app()->user->isGuest),
  array('label'=>'Logout ('.Yii::app()->user->name.')', 
   'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
 ),
)); ?>

The controller presentation are easily distinguished, very easily to control: to modify individual file like c:/php_app/yii/testdrive/protected/views//site/pages/about.php will change the outlook and content of ‘About‘ menu.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: