bakeする(controller,view)

次に bake のメニューから、 C を選んでコントローラを作ります。

> C
---------------------------------------------------------------
Bake Controller
Path: /Users/myname/Sites/cake/app/controllers/
---------------------------------------------------------------
Possible Controllers based on your current database:
1. Favorites
2. Members
3. MembersFavorites
4. Types
5. Users
Enter a number from the list above,
type in the name of another controller, or 'q' to exit  
[q] > 2

モデルの時と同様の選択画面になるので、

2. Members
を選択します。

---------------------------------------------------------------
Baking MembersController
---------------------------------------------------------------
Would you like to build your controller interactively? (y/n) 
[y] > y

とりあえずYESですね。

Would you like to use dynamic scaffolding? (y/n) 
[n] > n

スキャフォルドをするかどうかですが、しないのでNOです。

Would you like to create some basic class methods 
(index(), add(), view(), edit())? (y/n) 
[n] > y

indexとかaddとかの基本のアクションを作るかどうかですね。ここでYESです。

Would you like to create the basic class methods for admin routing? (y/n) 
[n] > y

adminルーティングを使うかどうかです。これはYESです。

Would you like this controller to use other helpers
besides HtmlHelper and FormHelper? (y/n) 
[n] > n
Would you like this controller to use any components? (y/n) 
[n] > n
Would you like to use Session flash messages? (y/n) 
[y] > y

---------------------------------------------------------------
The following controller will be created:
---------------------------------------------------------------
Controller Name:
 Members
---------------------------------------------------------------
Look okay? (y/n) 
[y] > y

その後はそのままです。 /app/controllers/members_controller.php が作られました。

次に、 V を選んでビューを作ります。

> V
---------------------------------------------------------------
Bake View
Path: /Users/myname/Sites/cake/app/views/
---------------------------------------------------------------
Possible Controllers based on your current database:
1. Favorites
2. Members
3. MembersFavorites
4. Types
5. Users
Enter a number from the list above,
type in the name of another controller, or 'q' to exit  
[q] > 2

やはり2番のMembersを選んで進みます。

Would you like bake to build your views interactively?
Warning: Choosing no will overwrite Members views if it exist. (y/n) 
[n] > y

ここはYESにします。

Would you like to create some CRUD views
(index, add, view, edit) for this controller?
NOTE: Before doing so, you'll need to create your controller
and model classes (including associated models). (y/n) 
[y] > y

ここもとりあえずYESにします。

Would you like to create the views for admin routing? (y/n) 
[n] > y

admin 用のviewを作るかどうかです。これもYESにします。

/app/views/ 以下に members というフォルダーが作られ、 index.ctp 他の各アクション用ビューが自動生成されます。 登録フォームの view は以下のようになりました。

<div class="members form">
<?php echo $this->Form->create('Member');?>
 <fieldset>
  <legend><?php __('Add Member'); ?></legend>
 <?php
  echo $this->Form->input('email');
  echo $this->Form->input('password');
  echo $this->Form->input('type_id');
  echo $this->Form->input('birthday');
  echo $this->Form->input('img1');
  echo $this->Form->input('img2');
  echo $this->Form->input('Favorite');
 ?>
 </fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
</div>
<div class="actions">
 <h3><?php __('Actions'); ?></h3>
 <ul>

  <li><?php echo $this->Html->link(__('List Members', true), array('action' => 'index'));?></li>
  <li><?php echo $this->Html->link(__('List Types', true), array('controller' => 'types', 'action' => 'index')); ?> </li>
  <li><?php echo $this->Html->link(__('New Type', true), array('controller' => 'types', 'action' => 'add')); ?> </li>
  <li><?php echo $this->Html->link(__('List Favorites', true), array('controller' => 'favorites', 'action' => 'index')); ?> </li>
  <li><?php echo $this->Html->link(__('New Favorite', true), array('controller' => 'favorites', 'action' => 'add')); ?> </li>
 </ul>
</div>

users についても同じようにしてコントローラとビューを作ります。