One of the basic characteristics of Yii modules is that they cannot be deployed alone. In order to have your web application work, one needs a central module that can process all request, and relay the information to other modules when necessary. This central module should be able to keep application-level configuration settings. This is where the CApplication becomes useful.

The CApplication class extends the CModule class given a module the ability to be used as a standalone module. It is a module that prescribes how a user request should be handled. It is an abstract class, meaning one cannot create an instance of it. Since it keeps application-level configuration, it defines certain properties to help it achieve its functionality.

the charset currently used for the application. Defaults to 'UTF-8'.

controller read-only
public CController getController()
the currently active controller. Null is returned in this base class.

public string getExtensionPath()
public void setExtensionPath(string $path)
Returns the root directory that holds all third-party extensions.

public string getHomeUrl()
public void setHomeUrl(string $value)

public string getLanguage()
public void setLanguage(string $language)
Returns the language that the user is using and the application should be targeted to.

public string $name;
the application name. Defaults to 'My Application'.

public string getRuntimePath()
public void setRuntimePath(string $path)
Returns the directory that stores runtime files.

public string $sourceLanguage;
the language that the application is written in. 

CApplication has six life cycles it undergoes when responding to a user request. The first three is activated when its constructor is called, and the last three is when its run() method is called.

  1. load application configuration;
  2. set up class autoloader and error handling;
  3. load core application components;
  4. onBeginRequest: An event raised for any attached listener to pre-process the user request;
  5. processRequest: process the user request;
  6. onEndRequest: An event raised for any attached listener to post process the user request;

From the above one can notice one important method processRequest().It is the place where the actual request processing work is done. It signature is

abstract public void processRequest(). 

Starting from lifecycle 3, if a PHP error or an uncaught exception occurs, the application will switch to its error handling logic and jump to step 6 afterwards.