Trying to understand the principles of Yii !

Hi all.

My first step is read step by step "The Definitive Guide to Yii" and trying to dev a minimal application and figure out it's behavior in spite of what is written in the manual.

As an older Prado's developer, I am trying to see the diferences of both, and I would like to share some questions or doubts finding in my studies.

Go to someones:

  1. YIIC generates all sort of php code without ending php tag "?>". Why ?

  2. Application Life Cycle hide important aspects that are not so easy to be deducted (for a newbie).

Suppose that I has created (with yiic) a MyApp application and I call it with http://localhost/MyApp. What exactly we can see into App life cycle ?

2.1) Apache seeks and finds the app entry point: index.php at /protected subdir;

2.2) This script, includes yii framework and creates (instancing) the App singleton object configured by /protected/config/main.php script;

2.3) The main.php with "return array();" as a minimal code, deliberately invoking the /protected/controllers/SiteController.php script;

I will stop here and comment 2 arbitrariness that surprised me.

First of all why I need to say for a App constructor that the application configuration file is one with a specific name? Why doesn't the constructor search for a file with a standardized name? Something like "application.cfg" file !?

Second. Unlike the use of standardized names, Who said to maim.php file to sidetrack the flow to the SiteController file? By chance the Application's defaultController property contains its default value equal to "site"?



  1. This is to avoid displaying any spaces that may be inadvertently left behind ?>. Many frameworks have been using this way.

  2. The entry script file in Yii is like that in Prado. It creates an application instance (again like Prado) and configure it with initial property values as specified in a config file (yiic uses protected/config/main.php). This config file is similar to the application.xml file in Prado, except that it is given as a PHP script rather than an XML file.

  3. Once the application is created, the entry script calls its run() method. The application then checks the 'r' parameter to decide which controller and action to perform (like calling the page in Prado).

Hi qiang. Good points.

  1. ok

  2. ok - nothing against it.

  3. So, the original url is required to contain parameters? By the way, when I run yiic to create app structure, the main.php file has been created without the definition of defaultController property. The default value of this property is "site" (into CApplication class file) ?

Go ahead!


  1. Yes. If you don't supply such a parameter, it will use default values, and that is what defaultController will be used for. In the main.php, you can set this property. If not, it will default to 'site'.

ok. I understand and agree.

BTW, how can I become a Portuguese translator (of "the definitive guide" doc) ?



I just added you to the yiidoc team. Thanks for willing to help translate the doc!

Thanks quiang.

Know I only need to learn how to use googledoc tool !