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

How AutoGenerate classes with cakePHP 2.7.x?

似乎在任何地方都没有关于它的文档。任何帮助将不胜感激。

文档位于 http://book.cakephp.org/2.0/en/console-and-shells.html。根据 OP 的建议将此添加为答案。

如果我没记错的话,你的意思是 Cake Console 和 Shell 可以为你的应用程序生成控制器、模型和视图的自动生成代码。

您可以参考这里了解更多信息http://book.cakephp.org/2.0/en/console-and-shells.html

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

示例:

$cake bake all

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

---------------------------------------------------------------
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 控制台和 shell。