很久没有更新过 Webbaker 了,在 CakePHP 0.10.0.1217_alpha 发布之后,之前的 Webbaker 版本就已经不能正常使用了。本来以为没什么人用这个,所以也就懒得改,没想到前几天有人给我发邮件,问我为什么不能在现在的 CakePHP 版本下使用,我只好很不好意思地回信告诉他我的业余时间太少,所以没有更新。。。
ChangeLog:
- Updated to work with Cake_0.10.0.1217_alpha and above version (current is RC2).
- Add bake type. Currently it has three types: "empty", "scaffold" and "popular".
- Empty: will create empty view files.
- Scaffold: will use "scaffold" in the controller file and don't create any view file.
- Popular: will create popular CRUD controller codes and view files.
- If the action is specified with an underscore (_private_action) then it will not create an equivalent view.
Download it !
这个版本的 Cake 有了不少修改,需要修改模块变量名等等,具体关键的修改如下:1. New Model References
Any instance of a model should be referenced as CamelCase.
(old) $this->models['post']->findAll()
(new) $this->Post->findAll().
2. Association References
Associated data is returned in ModelName array now.
(old) $data['modelname']['id'];
(new) $data['ModelName']['id'];
3. CamelCased models with associations:
All Associations should be singular CamelCased, since we are associating models.
var $belongTo = 'SomeOtherModel,SomeOtherModel1';
var $hasOne = 'SomeOtherModel,SomeOtherModel1';
var $hasMany = 'SomeOtherModel,SomeOtherModel1';
var $hasAndBelongsToMany = 'SomeOtherModel,SomeOtherModel1';
For more information on associations:
http://wiki.cakephp.org/docs:understanding_associations
4. Table underscores:
If you CamelCase your models to replicate your database tables.
The table names and URLs to the controller will be automatically underscored on PHP5.
On PHP4 set your controller (var $name ='Posts') and model (var $name = 'Post')
Adding var $useTable = 'my_underscore_table'; to your model can also be used if
your table name is different from your model name.
5. CamelCase on helpers and components.
var $components = array('ComponentName');
accessing components in the controller is CamelCased
$this->ComponentName->method()
var $helpers = array('Html','HelperName');
accessing helpers in the view is camelBacked
$helperName->method()
6. Update to database.php.default
You must now set connection type.
The port is optional同时我也更新了 Cake AJAX Blog Demo,使可以在最新的版本 Cake_0.10.0.1217_alpha 下运行。
今天更新了 Cake AJAX Blog Demo,实现了使用拖曳操作删除文章的功能,将文章标题拖曳到 Wastebin 上即可完成删除操作,试试吧
PS:现在发现 AJAX 越来越有意思了,呵呵 
前些天 Tristan Zajonc 在 Cake Group 中问有没有人愿意维护 Cake AJAX Demo,因为他的这个版本所使用的 Cake 以及 prototype 都太老了,昨晚闲着,就把源代码下载下来阅读,并进行了修改,其实 cake 实现 AJAX 还是比较简单的,有很多现成的方法可以直接调用。我的修改主要是将之前的一些库使用新版的 Cake 替代,并更新了 prototype,同时增加了 [url]http://script.aculo.us[/url] 的 JavaScript,为之后实现拖曳删除操作做准备。
查看新版本的 Cake AJAX Blog Demo。
源代码下载。
以后有时间会继续完善。
这两天闲着没事,写了一个 Cake 的基于 WEB 的 bake 工具,取名叫“WebBaker”吧,呵呵
WebBaker 是一个基于 WEB 的 CakePHP Framework 创建工具,它可以自动创建 Cake 需要用到的 MVC 文件,当前的版本是 0.10.0_dev,此版本号与最新的 Cake 发行版相对应。点击此处下载 WebBaker_0.10.0_dev.zip。