Thursday, 17 April 2014

Yii Framework Tutorial Set 2


       Before reading this post you must read my previous post Yii Framework Tutorial Set 1. Its been a long time i am writing this post, because i was busy with my Yii projects. In the previous post you have successfully installed Yii framework application. You can check it at this below url:

If everything is Ok, it will be like this.
You can change the contents of this home page at
protected/views/site/index.php .
in the same way you can edit about us page at
contact us page at
log in page at
and finally error page at


           In default, The application name will be "My Web Application". You can change this to your preferred name at protected/config/main.php . You have to change the 'name' parameter in array. In the same file you have to change Database details also. In default, DB connection is connected to SQLITE database. So, you must change the DB Details also.


        Do you confused by thinking from where this layout came? The main layout files for yii framework is in  protected/views/layouts/ .
at this layouts folder you can see three different files as below.
  • main.php
  • column1.php
  • column2.php
It means in default we have two different layout at present (You can also add layout files and modify these two files based on you view). As the name suggests the difference between these two layout is first one is single column and second is double column with sidebar. Where does the layout file is selected?      The layout for particular page or view can be selected in their respective controller file. For instance, in controllers/sitecontroller.php we have variable $layout. In this variable we have to specify either column1 or column2 (note: don't use column1.php and column2.php, Yii will point this automatically. In the same way at any situation in you want to include any file don't use php extension).


         When you open these layout files, index.php, contact.php all html elements will use blueprint css framework. I prefer you to go through this blueprint css at their official website for your reference i will give you one example:
          To design a DIV with 590px you can specify class name as span-15. 
So, you don't need to write your own css for each and every html elements. Once again i am asking you to read about blueprint css framework to design your application effectively.        




  1. Nice information described in simple manner so everyone can understand it. Thanks for sharing wonderful information like this.
    PHP Web Development Company in Indore

  2. Hi! I'm also a PHP Developer, The above blogging information is very useful to Us...

    Yii Support


  3. I'm also a Developer but i'm adult stage in this Development, Thank you for your info, It was very useful to me...

    Yii Framework Development Company India

  4. Great blog. All posts have something to learn. Your work is very good and i appreciate you and hoping for some more informative posts.keep writing
    Web development Company in India Company | Web development Company Bangalore
    Web Development Company in Bangalore | Responsive Web development