兩種方式可以建立module
1. Gii
可以看到yii會幫我們建立以下的資料:
1. cart資料夾
-CartModule.php
2. cart/controllers資料夾
-DefaultController.php
3. cart/views資料夾
4. cart/views/default資料夾
-index,php
2. yiic shell (參考這篇)
跟用Gii建立module的差別在, shell會多新增下面幾個資料夾:
1. components
2. messages
3. models
4. views/layouts
整體來看用shell建立的是比較完整, 不過如果你的module不會用到components跟messages的話, 其實用Gii就夠了!
不用擔心models, 因為一樣可以透過Gii來替你的module建立model, 還有CRUD
(可以參考這篇)
3. Set Module
1. 進到config/main.php
2. 將你的模組 (module) 加進去, 假設你的模組叫user:
'modules' => array(
'user',
// uncomment the following to enable the Gii tool
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'you password',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters' => array('127.0.0.1','::1'),
),
沒有留言:
張貼留言