1. 程式人生 > >yii1.1 專案初始化配置

yii1.1 專案初始化配置

在 yii 官網,http://www.yiichina.com/download 中的 git或者直接下載原始碼包!

在 deome 中的   blog 中 是這樣的 目錄:

這裡要說的   預設的  控制器跟檢視都在是在 protected 裡面的,我們要修改預設的話,

 在  config/main.php中的配置中 要 配置下  引數:

// 應用元件
'components'=>array(
'user'=>array(
// 啟用基於cookie的身份驗證
'allowAutoLogin'=>true,
),
'db'=>require(dirname(__FILE__).'/database.php'
), 'errorHandler'=>array( //使用站點/錯誤動作顯示錯誤 'errorAction'=>'site/error', ), 'urlManager'=>array( 'urlFormat'=>'path', 'rules'=>array( 'post/<id:\d+>/<title:.*?>'=>'post/view', 'posts/<tag:.*?>'=>'post/index', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>'
, ), ), 'log'=>array( 'class'=>'CLogRouter', 'routes'=>array( array( 'class'=>'CFileLogRoute', 'levels'=>'trace', //級別為trace 'categories'=>'system.db.*' //只顯示關於資料庫資訊,包括資料庫連線,資料庫執行語句 ), // uncomment the following to show log messages on web pages /* array( 'class'=>'CWebLogRoute',
), */ ), ), ),

 如果用gii 的  也就是 不用預設的 控制器跟 檢視的話, 這就要設定了:

gii新建的什麼目錄 就要在這裡設定空陣列的名字.

'modules'=>array(
'admin'=>array(),
'reception'=>array(),
'test'=>array(),
//取消註釋以啟用GII工具
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'123',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
),

 用gii生成 modules  控制區都弄好之後呢,重要的就是設定檢視目錄了

在 父級 積類,也就是全域性控制器中預設是

class Controller extends CController
{
/**
    * @var string the default layout for the controller view. Defaults to 'column1',
    * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
    */
public $layout='//layouts/main'; // 全域性佈局目錄
/**
    * @var array context menu items. This property will be assigned to {@link CMenu::items}.
    */
public $menu=array();
/**
    * @var array the breadcrumbs of the current page. The value of this property will
    * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
    * for more details on how to specify this property.
    */
public $breadcrumbs=array();
public function init()
    {
        Yii::app()->themeManager->setBasePath(getcwd()."/themes");//檢視指向對應main.php
}
}

這樣就可以 gii生成的 控制器 檢視會讀取 protected 同級下的 themes 中的 v1.0 下的 views的檢視了/ 目錄層級要一樣!

新手搗鼓搗鼓,有錯誤還請指出來哈,謝謝!