• Blogs (9)
    • šŸ“± 236 - 992 - 3846

      šŸ“§ jxjwilliam@gmail.com

    • Version: ā€šŸš€ 1.1.0
  • 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:

    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.