如何使用cakePHP 2.7.x自动生成类?

时间:2015-11-09 09:13:42

标签: cakephp-bake cakephp-2.7

似乎没有任何关于它的文档。任何协助将不胜感激。

2 个答案:

答案 0 :(得分:1)

该文档可在http://book.cakephp.org/2.0/en/console-and-shells.html获得。根据OP的建议添加了这个答案。

答案 1 :(得分:1)

如果我没弄错的话,你的意思是Cake Console& Shell可以生成Controller,Model&的自动生成代码。查看您的应用程序。

您可以在此处参阅更多信息http://book.cakephp.org/2.0/en/console-and-shells.html

您可以使用'bake' shell生成mvc结构。

示例:

$cake bake all

将在您的数据库中输出所有可能的表,如下所示

---------------------------------------------------------------
Bake All
---------------------------------------------------------------
Possible Models based on your current database:
1.posts
2.users
Enter a number from the list above,
type in the name of another model, or 'q' to exit

如果您输入1,那么结果将如下所示:

Baking `index` view file...

Creating file /Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/index.ctp
Wrote `/Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/index.ctp`

Baking `view` view file...

Creating file /Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/view.ctp
Wrote `/Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/view.ctp`

Baking `add` view file...

Creating file /Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/add.ctp
Wrote `/Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/add.ctp`

Baking `edit` view file...

Creating file /Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/edit.ctp
Wrote `/Applications/XAMPP/htdocs/AQMCorporate/aqmtest/View/Posts/edit.ctp`

Bake All complete

你可以使用CakePHP控制台&外壳