How to Change Default Yii Application directory structure

Default user generated Yii application directory structure looking like this

yii directory structure

If you want to change these files structure follow my steps

Create new folder called www.

Cut and paste all folder and files (assets, css, images, themes, index.php, index-test.php) except protected folder into www folder.

Now open index.php file using any code editor. (Its available in www folder which newly created)

Its looking like this.


// change the following paths if necessary

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


Down two levels in yii directory and down one level in config file.

yii directory

Now restart WampServer. Add extra www path to run your yii application.

Before path
: http://localhost/firstapp/
After path: http://localhost/firstapp/www/

If you are using Virtual Host change the path in httpd-vhosts.conf file.
Changing default directory structure is create a more secure environment.