Yii Installation on IIS server: Application runtime path is not valid issue

After Yii installation on IIS then developer face problem to run the demo application. And following error message appear in-front of them

“Application runtime path “C:\inetpub\wwwroot\projectname\protected\runtime” is not valid. Please make sure it is a directory writable by the Web server process.”

To solve this issue

1. Open IIS manager and select the project folder name from all available sites

2. From right pane “Actions” please select “Edit Permissions”  and then give full permission to user “IUSR” and then save and restart IIS

Reload your URL and see the result.

Install, update and use Yii with WAMP server

Here I am going to post my Wiki post from Yii Framework forum. I hope this will help all.

Here I am describing how you can install and update Yii in WAMP sever.

Follow the following step by step procedures to find your destination-

Step 1: Assigning PHP engine location path in system variable

  • Go to “My Computer” ->Right click and select “Properties”
  • Click “Advanced system settings” from left pane
  • Under “Advanced” tab click on “Environment Variables”
  • Under “System variables” scroll down and find text “Path” then Double click on it
  • Now enter your PHP engine location on end of the “variable value” field

    i.e. for me I entered “C:\wamp\bin\php\php5.3.10”. Just enter location without double quotes

  • Click ok and finally exit from this.

Step 2: Create project folder under “www”

Just create a blank folder in “www” that should be your project name. i.e “bid” You can also make this using command window. For this-

  • Open command window
  • C:>cd wamp\www\
  • C:\wamp\www>mkdir bid

Step 3: Download Yii framework and put into www directory and install the framework for bid project

  • Go “http://www.yiiframework.com/” and download latest Yii framework zipped file
  • Unzip and rename folder to “yii”
  • Using command-
    • C:\wamp\www>cd yii\framework\
    • C:\wamp\www\yii\framework>yiic webapp C:\wamp\www\bid

      Create a Web application under ‘C:\wamp\www\bid’? [Yes|No] y

      Your application has been created successfully under C:\wamp\www\bid.

Now you are ready to browse your project by accessing the URL : http://localhost/bid/

If you want to use this installation for multiple project then just copy “bid” folder and past and rename with your project name. Its better if you make “bid” folder as your backup project folder then when you need to work with a new project then just you need to copy and past this folder and rename to your new project name.

If you want to install an updated version of Yii framework then please download updated version zipped folder from “http://www.yiiframework.com/” and unzip. After unzip the file just copy the framework folder and then go “yii” folder under “www” directory and just replace previous framework folder with latest one.

Enjoy and explore Yii………..

How can use Yii Bootstrap GridView in your application

This is very easy. Just need to follow few things. I suggest to browse Yii Bootstrap site for more details.

$this->widget('bootstrap.widgets.TbGridView', array(
   'type'=>'striped bordered condensed',


       array('name'=>'last_name', 'header'=>'Name'),
       array('name'=>'email', 'header'=>'Email Address'),
       array('name'=>'mobile_phone', 'header'=>'Mobile Phone'),
       array('name'=>'city', 'header'=>'City'),
       'htmlOptions'=>array('style'=>'width: 50px'),


Display input element on dropdown selection in Yii

To display an input element on dropdown selection is very easy. Just follow few steps-
Using JavaScript:
Selection dropdown 1:

<div class="row">  
   <?php echo $form->labelEx($model,'status'); ?>

   <?php echo $form->dropDownList($model,'status',
      array('onchange'=>'return checkStatus(this.value)'));

   <?php echo $form->error($model,'status'); ?>

    Hidden div. Will active if selection is true
    <div id="hiddendiv" style="display:none">                 
        <div class="row">
           <?php echo $form->labelEx($model,'category'); ?>
           <?php echo CHtml::activeDropDownList($model,'category', 
                array('prompt'=>'Select') ); ?>
           <?php echo $form->error($model,'category'); ?>
function checkStatus(obj)
       return false;               
       return false;                
By Using Yii Ajax-

In View
        <?php echo $form->labelEx($model,'status'); ?>

        <?php echo $form->dropDownList($model,'status',
        array('0' =>'In active', '1'=> 'Active'),

        array( 'onChange' => 'javascript:description()', 
        <div id="status_id"></div>
        <?php echo $form->error($model,'status'); ?>

    In Controller-
    public function actionfunctionName()
           //For only text field
           //echo CHtml::textField("Employment",'applying_position'); 

           // For Dropdownlist

           echo $form->dropDownList($model,'status',

Hope that will help us.

Create custom Input validation rules in Yii model for dependent input field

Suppose we want to create a dependent input validation rule in Yii model for dependent 2 input field. Field one is status and field two is reason. If user select a status from dropdown list then they must be fill-up reason field. If not then it will show a error message.

In model rules-

public function rules()
   return array(
   array('status', 'reasonValidators'),

and validation function-

public function reasonValidators()
  if ((int)$this->status=="Yes")
    $labels = $this->attributeLabels(); // Getting labels of the attributes
       $this->addError("reason", $labels["reason"]." cannot be blank.");
    // More dependent on type can be written here