Install Yii without a Database
Blogs20122012-04-06
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_appyii'
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_appyiiframework
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:
(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.