This file describes the differences between **pure yii** application and **vkclone**.
Content:
1. Application changes
2. Controller changes
3. Console commands changes
4. Module directory changes
5. Gearman worker application
6. Configuration changes
---
###1. Application changes
1. Force all modules initiation in **index.php** and **protected/yiic.php**.
---
###2. Controllers changes
There's 2 base controller classes: **FrontEndController** and **BackEndController**.
```code
└── CController
└── Controller
├── FrontEndController
└── BackEndController
```
**BackEndController** has enabled accessControl to deny any users but admins.
---
###3. Console commands changes
There's the base class **ConsoleCommand**.
It contains a list of useful in cli-mode methods:
1. `getUrlContents()` and `performPostRequest()` are shortcuts to curl functions.
2. `terminate()` is used to terminating cli application and saving log to directory **protected/logs/**.
3. `convertToCp()` and `convertToUnicode()` convers text encoding between **cp1251** and **utf-8** encodings.
---
###4. Module directory changes
1. **Module.php** - modules class. (base class is WebModule).
2. **meta.xml** - meta information about module (xml file).
---
###5. Gearman worker application
Extension **gearman-application** allows you use existing yii application as a gearman worker.
The base class of gearman worker: **Worker**.
To add a command to worker, add command to **router** component.
An example of adding new command in **/protected/config/gearman/components.php**.
An example of gearman worker: **/protected/workers/GalleryWorker**.
---
###6. Configuration changes
Configuration in vkclone is more complex than in basic yii application.
Vkclone builds configuration for application (which can be `web`, `console` or `gearman`) in 4 steps:
1. On the first step, Yii gets **protected/config/main.php** content. It is the base configuration.
2. On the second step, Yii takes configuration from previous step and merges its `modules` section with **protected/config/*application*/modules.php** file. If file is not present, Yii does nothing.
3. On the third step, Yii takes configuration from previous step and merges its `components` section with **protected/config/*application*/components.php** file. If file is not present, Yii does nothing.
4. On the fourth step, Yii takes configuration from previous step and merges it with **protected/config/local/*application*.php** file. If file is not present, Yii does nothing.
Code that does merging is like:
```php
$app = 'web';
$config = require 'protected/config/main.php';
if (file_exists('protected/config/'.$app.'/modules.php'))
$config = CMap::mergeArray($config['modules'], require 'protected/config/'.$app.'/modules.php');
if (file_exists('protected/config/'.$app.'/components.php'))
$config = CMap::mergeArray($config['components'], require 'protected/config/'.$app.'/components.php');
if (file_exists('protected/config/local/'.$app.'php'))
$config = CMap::mergeArray($config, require 'protected/config/local/'.$app.'.php');
```
For example, web-app configuration will be made of the following files:
* **protected/config/main.php**
* **protected/config/web/modules.php**
* **protected/config/web/components.php**
* **protected/config/local/web.php**
Local directory is for your manual changes because all non-example files inside it are not under git control.