CakePHP bakeによる高速開発 – 虎の巻

bakeとは?


bakeCakePHPMVCWebPHP
MVC




 
 
 
 
 
 
 ////
 
 
 
 ///
 
 
 




bake

bake

Web


WebCakePHP ACL bake

 crud////User belongsTo Role 


 users  roles 
CREATE TABLE IF NOT EXISTS `roles` (
  `id` int(4) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `created` datetime DEFAULT NULL,
  `modified` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(4) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `role_id` int(4) NOT NULL,
  `created` datetime DEFAULT NULL,
  `modified` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CakePHP


 XAMPP使c:¥xampp¥htdocs¥bake CakePHP

bake


bake使PHPbakePATH


1. 

2. php

cd c:¥xampp¥php

XAMPPPHP.EXE

3. PATH

set path=%path%;%cd%

4. CakePHPcake  console 

cd c:¥xampp¥htdocs¥bake¥cake¥console

5. PATH

set path=%path%;%cd%

6. CakePHP

cd c:¥xampp¥htdocs¥bake

7. bake

cake bake

bake

Welcome to CakePHP v1.3.14 Console

App : app
Path: C:¥xampp¥htdocs¥bake¥app

Your database configuration was not found. Take a moment to create one.

Database Configuration:

Name:
[default] >



bake

Name:
[default] >

 

[default] >
bake 

Enter[default]

Driver:
[mysql] >

 

MySQL使Enter[mysql]

Persistent Connection:
[n] >

 

Enter[n]

Database Host:
[localhost] >

 

Enter[localhost]

Port:
[n] >

 

Enter[n]

User:
[root] >

 

Enter[root]


Password:
>

 

Enter


Database Name:
[cake] >

 

Enter

Table Prefix:
[n] >

 

Enter[n]

Table encoding:
[n] >

 

utf8Enter

Look okay? (y/n)
[y] >

 


The following database configuration will be created:

Name: default
Driver: mysql
Persistent: false
Host: localhost
User: root
Pass: ****
Database: cake
Encoding: utf8

Look okay? (y/n)
[y] >

Enter[y]

Do you wish to add another database configuration?
[n] >



Enter[n]

database.php

app/config database.php 



> app/config/database.php
<?php
class DATABASE_CONFIG {

 var $default = array(
  'driver' => 'mysql',
  'persistent' => false,
  'host' => 'localhost',
  'login' => 'root',
  'password' => 'root',
  'database' => 'cake_bake',
  'encoding' => 'utf8'
 );
}
?>



MVC


cake bakebake


Welcome to CakePHP v1.3.14 Console

App : app
Path: ¥xampp¥htdocs¥bake¥app

Interactive Bake Shell

[D]atabase Configuration
[M]odel
[V]iew
[C]ontroller
[P]roject
[F]ixture
[T]est case
[Q]uit
What would you like to Bake? (D/M/V/C/P/F/T/Q)
>

 bake 

mEnter

Possible Models based on your current database:
1. Role
2. User
Enter a number from the list above, type in the name of another model, or q to exit

 


Role  User 

 User Enter[2]

A displayField could not be automatically detected would you like to choose one? (y/n)

 displayField

nEnter[n]

displayField 使 scaffold  find(list) 使 name  title 使

Would you like to supply validation criteria for the fields in your model? (y/n)
[y] >

 

Enter[y]



Field: id
Type: integer

Please sélect one of the following validation options:

1  alphanumeric
2  between
3  blank
4  boolean
5  cc
6  comparison
7  custom
8  date
9- decimal
10  email
11  equalto
12  extension
13  inlist
14  ip
15  maxlength
16  minlength
17  money
18  multiple
19  notempty
20  numeric
21  phone
22  postal
23  range
24  ssn
25  time
26  url
27  userdefined
28  uuid
29  Do not do any validation on this field.
 or enter in a valid regex validation string.
[29] >

 id

id[29]Enter
username19  notemptyEnter

bake Enter



Whoud you like to define model associations (hasMany, hasOne, belongsTo, etc.)? (y/n)
[y] >

 

User User bolongsTo Role yEnter

User belongsTo Role. (y/n)
[y] >

yEnter

Would you like to define some additional model associations? (y/n)
[n] >

 

[n]Enter

Look okey? (y/n)
[y] >

 

yEnter


The following Model will be created:

Name: User
DB Table: users
Validation: Array
(
  [username] => Array
    (
      [notenpty] => notempty
    )
  [password] => Array
    (
      [notempty] => notempty
    )
  [role_id] => Array
    (
      [numeric] => numeric
    )
)
Associations:
 User belongsTo Role

Look okay? (y/n)
[y] >

 User 

SimpleTest is not installed. Do you want to bake unit test files anyway_ (y/n)
[y] >

 User

yEnter

SimpleTest

app/models user.php 

 Role 


bake 
cEnter

Enter a number from the list above, type in the name of another controller, or q to exit

User Enter[2]

Would you like to build your controller interactively? (y/n)

 

yEnter

Would you like to user dynamic scaffolding? (y/n)

 scaffold使

nEnter

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

 ///

yEnter

Would you like to create the basic class methods for admin routing? (y\n)

 

nEnter

Would you like this controller to user other helpers basides HtmlHelper and FormHelper? (y/n)

 HTMLForm使

nEnter

Would you like this controller to use any components? (y/n)

 使

nEnter

Would you like to use Session flash messages? (y/n)

 使

yEnter

Look okey? (y/n)

 

yEnter

User

app/controllersusers_controller.php


bake 
vEnter

Enter a number from the list above, type in the name of another controller, or q to exit.

User Enter[2]

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

 ///

yEnter

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

 

nEnter

User

app/viewsusersadd.ctpedit.ctpindex.ctpview.ctp

bake


bake

////

bake使15
MVC

bake

bake


bakebakeMVC
bake



bakeMVC
bake

Comments

コメントを残す