The very base structure of Yii application

This is some modification of Neil McGuigan’s article.

The base structure for Yii app goes as follows:

/index.php
/protected/components/controller.php
/protected/config/main.php
/protected/controllers/SiteController.php
/protected/runtime/
/protected/views/site/index.php


/index.php
Notice that you should change path to Yii entry script at line 3 in order to make it work for your Yii setup.

<?php

$yii=dirname(__FILE__).'/../yii/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';

defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($yii);
Yii::createWebApplication($config)->run();

/protected/components/controller.php

<?php
class Controller extends CController
{
	public $layout='//layouts/column1';
	public $menu=array();
	public $breadcrumbs=array();
}

/protected/config/main.php

<?php
	return array(
		'import' => array(
			'application.components.*',
		),
	);

/protected/controllers/SiteController.php

<?php
	class SiteController extends Controller
	{
		public function actionIndex()
		{
			$this->render('index');
		}
	}
?>
Share
Posted By admin

Leave a Reply

You must be logged in to post a comment.