cake php官网:http://cakephp.org/

使用bake生成代码.

1:首先你要把数据库建好,例如我们使用PowerDesigner把数据库设计好,导出sql语句,在mysql中创建数据库tfss,创建两个简单的表(特别需要注意表名以及外键的命名,请参考cakephp的命名规范):
   drop table if exists admingroups;
   /*==============================================================*/
   /* Table: admingroups                                           */
   /*==============================================================*/
   create table admingroups
   (
       id                   int not null auto_increment comment '管理组ID',
       ac_user              int not null default 1 comment '允许创建用户(0: false ; 1: trure)',
       ac_class             int not null default 1 comment '允许创建班级组别(0: false ; 1: trure)',
       primary key (id)
   );
   alter table admingroups comment '管理组表';

drop table if exists usergroups;
   /*==============================================================*/
   /* Table: usergroups                                            */
   /*==============================================================*/
   create table usergroups
   (
       id                   int not null auto_increment comment '用户组ID',
       admingroup_id        int not null default 0 comment '用户组类型1:学生;2:校长;3:老师)',
       group_name           varchar(50) not null default '' comment '用户组名称(管理组为学生的:中1~中6总共6个级别)',
       user_count           int not null default 0 comment '用户数量',
       primary key (id)
   );
   alter table usergroups comment '用户组表';

2: 首先要将php的php.exe加入环境变量中,例如我的php安装在E:\work\Server\PHPCore下,将该路径加入到path中

3: 在命令行里面执行如下命令:php cakephp的bake文件路径 bake
   例如你的cakephp解压文件全部放在
   “E:/work/PHPPro/CakePHPTest/”目录下
   那么则在命令行执行: php E:/work/PHPPro/CakePHPTest/lib/Cake/Console/cake.php bake

1)  首先要知道相关命令:
    [D]atabase Configuration
    [M]odel
    [V]iew
    [C]ontroller
    [P]roject
    [F]ixture
    [T]est case
    [Q]uit

2):执行了以上命令,开始配置数据库
   Welcome to CakePHP v2.1.0 Console
   ---------------------------------------------------------------
   App : app
   Path: E:\work\PHPPro\CakePHPTest\app\
   ---------------------------------------------------------------
   Your database configuration was not found. Take a moment to create one.
   ---------------------------------------------------------------

---------------------------------------------------------------
   Database Configuration:
   ---------------------------------------------------------------
   Name:
   [default] > default
   Datasource:(Mysql/Postgres/Sqlite/Sqlserver)
   [Mysql] > mysql
   Persistent Connection? (y/n)
   [n] > n
   Database Host:
   [localhost] > localhost
   Port?
   [n] > 3306
   User:
   [root] > root
   Password:
   > 000000
   Database Name:
   [cake] > tfss
   Table Prefix?
   [n] > n
   Table encoding?
   [n] > n

---------------------------------------------------------------
    The following database configuration will be created:
    ---------------------------------------------------------------
    Name:         default
    Driver:       mysql
    Persistent:   false
    Host:         localhost
    Port:         3306
    User:         root
    Pass:         ****
    Database:     tfss
    ---------------------------------------------------------------
    Look okay? (y/n)
    [y] > y
    Do you wish to add another database configuration?
    [n] > n

Creating file E:\work\PHPPro\CakePHPTest\app\Config\database.php
    Wrote 'E:\work\PHPPro\CakePHPTest\app\Config\database.php'

3)使用bake all生成m,v,c
    我们在命令行敲入: php E:/work/PHPPro/CakePHPTest/lib/Cake/Console/cake.php bake all
    执行如下:

Welcome to CakePHP v2.1.0 Console
    ---------------------------------------------------------------
    App : app
    Path: E:\work\PHPPro\CakePHPTest\app\
    ---------------------------------------------------------------
    Bake All
    ---------------------------------------------------------------
    Possible Models based on your current database:    
    1. Admingroup
    2. Usergroup
    Enter a number from the list above,
    type in the name of another model, or 'q' to exit
    [q] > 1

Baking model class for Admingroup...

Creating file E:\work\PHPPro\CakePHPTest\app\Model\Admingroup.php
    Wrote `E:\work\PHPPro\CakePHPTest\app\Model\Admingroup.php`
    PHPUnit is not installed. Do you want to bake unit test files anyway? (y/n)
    [y] > n

Baking controller class for Admingroups...

Creating file E:\work\PHPPro\CakePHPTest\app\Controller\AdmingroupsController.php
    Wrote `E:\work\PHPPro\CakePHPTest\app\Controller\AdmingroupsController.php`
    PHPUnit is not installed. Do you want to bake unit test files anyway? (y/n)
    [y] > n

Baking `index` view file...

Creating file E:\work\PHPPro\CakePHPTest\app\View\Admingroups\index.ctp
    Wrote `E:\work\PHPPro\CakePHPTest\app\View\Admingroups\index.ctp`

Baking `view` view file...

Creating file E:\work\PHPPro\CakePHPTest\app\View\Admingroups\view.ctp
    Wrote `E:\work\PHPPro\CakePHPTest\app\View\Admingroups\view.ctp`

Baking `add` view file...

Creating file E:\work\PHPPro\CakePHPTest\app\View\Admingroups\add.ctp
    Wrote `E:\work\PHPPro\CakePHPTest\app\View\Admingroups\add.ctp`

Baking `edit` view file...

Creating file E:\work\PHPPro\CakePHPTest\app\View\Admingroups\edit.ctp
    Wrote `E:\work\PHPPro\CakePHPTest\app\View\Admingroups\edit.ctp`

Bake All complete

4)关于.ctp模板文件
    如果使用zend studio是无法打开.ctp文件的,那么我就增加后缀名吧
    window -> Preferences -> General -> Content Types -> PHP Content type  添加*.ctp后缀
    添加文件关联
    window -> Preferences -> General -> Editor -> File Associations 添加关联

cakephp bake相关推荐

  1. cakephp bake(windows)

    建表 注册php变量,c:/wamp/php 放入path中 cd进入app目录,然后运行php c:/wamp/www/acl/cake/console/cake.php bake(c:/wamp/ ...

  2. CakePHP你必须知道的21条技巧

    原文链接:http://www.avatarfinancial.com/pages/cake/ 这篇文章可以说是CakePHP教程中最经典的了.虽然不是完整的手把手系列, 但作者将自己使用CakePH ...

  3. Create a restful application with AngularJS and CakePHP (I)

    为什么80%的码农都做不了架构师?>>>    #Create a restful application with AngularJS and CakePHP (I) #Prepa ...

  4. CakePHP 2.x CookBook 中文版 第三章 入门(三)

    为什么80%的码农都做不了架构师?>>>    路由 多数情况下,CakePHP 的默认路由都能够很好地工作.对用户体验和搜索引擎兼容敏感的程序员将注意到 CakePHP 的 URL ...

  5. cakephp视图用php文件,cakephp

    开发 编辑 必要条件 最好是带模块的,但不是必要条件. 或更高版本,没错,可以在php4或是5下面运行. 技术上来说,数据库不是必需的,但我们设想每个应用都会用到数据库,支持大部分数据库:: 3.Fi ...

  6. CAKEPHP 约定

    CakePHP 约定 我们坚信,约定优于配置(convention over configuration).虽然学习 CakePHP 的约定需要一些时间,但从长远来看,您可以节省时间.通过遵循约定,您 ...

  7. php cakephp like,cakephp常见知识点汇总

    本文实例总结了cakephp常见知识点.分享给大家供大家参考,具体如下: 1. 调用其他控制器的模板,重定向 方法一: 在此调用/views/tasks/tasks下的hello.ctp模板 $thi ...

  8. cakephp oracle,CakePHP入门(8)-创建Model

    一个最本的Blog程序除了能够发布文章,还应该让其它用户添加评论,前面的几步都是针对post作为例子,只有一个表,这里加入一些其它表,让一个blog具备基本一些最基本的元素. 删除之前的posts,重 ...

  9. CakePHP 2.x CookBook 中文版 第七章 模型

    模型 模型是应用程序中业务层的类. 这意味着它们负责管理工作域中几乎所有的与数据有关的东西:数据校验.交互和信息流演化. 通常模型类代理数据,用于 CakePHP 应用程序的数据访问,多数时候它们代理 ...

最新文章

  1. Go 学习笔记(32)— 类型系统(命名类型、未命名类型、底层类型、类型强制转换、类型别名和新声明类型)
  2. SAP MM 库存地点权限控制
  3. Java的三大特性之继承
  4. python编程小学生学好吗-小学生都开始学的Python编程到底是什么?
  5. boost::safe_numerics模块实现测试自定义异常的测试程序
  6. 1.8-samba 部署和优化-2
  7. css+html弄出哆啦a梦,祝儿童节快乐(DIV+CSS绘制哆啦A梦)
  8. java程序计时器_求完整简单java计时器小程序代码,急!!
  9. WannaCry反思:传统安全理念遭遇马奇诺防线式溃败
  10. mysql索引统计信息更新_MySQL索引统计信息更新相关的参数
  11. 60 秒 Linux 检查清单,快速初步定位你的性能问题
  12. NVM node版本管理工具的安装和使用
  13. Leetcode 76.最小覆盖子串
  14. Python + Selenium WebDriver Api 知识回顾
  15. AutoSar之CAN网络管理详解
  16. java获取时间天数间隔
  17. 西门子PLC内部的数据类型大全
  18. GEF原理及实现系列(四、控制器)
  19. 迁移学习---迁移学习基础概念、分类
  20. 无法从共享目录中映射段 linux,dopen():未作为root用户运行时,“无法从共享对象映射段”...

热门文章

  1. STM32F103ZET6程序移植为C8T6+C8T6下载程序flash timeout的解决方案
  2. 全球顶尖大学的UX课程资,免费拿走
  3. 完美日记90分钟卖1个亿,网红营销,只要学会这3招!
  4. python中wx是啥_python中wx模块的具体使用方法
  5. “边缘”当道,Aruba不仅有Wi-Fi,还有云原生交换机
  6. PTA 7-9 藏尾诗
  7. 如何启用计算机的远程服务,远程桌面服务,详细教您怎么打开远程桌面服务
  8. java 转 docx 生成 html 含图片,word公式,wps公式,自动编号,表格
  9. JMeter常见错误解决方法—你知道几种
  10. 怎么使用CAM350检查Gerber?