2015年10月20日火曜日

CakePHP 3で、スキャフォールド(scaffold)

CakePHP 3で、スキャフォールド(scaffold)です。公式サイトに「ブックマークチュートリアル(Bookmarker Tutorial)」が用意されているので、これに倣って進めていこうと思います。

スキャフォールド(scaffold)コマンド bake
$ bin/cake bake all users
$ bin/cake bake all bookmarks
$ bin/cake bake all tags
以下のように、必要なファイルを自動生成してくれます。
Welcome to CakePHP v3.1.1 Console
---------------------------------------------------------------
App : src
Path: /var/www/html/src/
PHP : 5.6
---------------------------------------------------------------
Bake All
---------------------------------------------------------------
One moment while associations are detected.

Baking table class for Users...

Creating file /var/www/html/src/Model/Table/UsersTable.php
Wrote `/var/www/html/src/Model/Table/UsersTable.php`
Deleted `/var/www/html/src/Model/Table/empty`

Baking entity class for User...

Creating file /var/www/html/src/Model/Entity/User.php
Wrote `/var/www/html/src/Model/Entity/User.php`
Deleted `/var/www/html/src/Model/Entity/empty`

Baking test fixture for Users...

Creating file /var/www/html/tests/Fixture/UsersFixture.php
Wrote `/var/www/html/tests/Fixture/UsersFixture.php`
Deleted `/var/www/html/tests/Fixture/empty`
Bake is detecting possible fixtures...

Baking test case for App\Model\Table\UsersTable ...

Creating file /var/www/html/tests/TestCase/Model/Table/UsersTableTest.php
Wrote `/var/www/html/tests/TestCase/Model/Table/UsersTableTest.php`

Baking controller class for Users...

Creating file /var/www/html/src/Controller/UsersController.php
Wrote `/var/www/html/src/Controller/UsersController.php`
Bake is detecting possible fixtures...

Baking test case for App\Controller\UsersController ...

Creating file /var/www/html/tests/TestCase/Controller/UsersControllerTest.php
Wrote `/var/www/html/tests/TestCase/Controller/UsersControllerTest.php`

Baking `index` view file...

Creating file /var/www/html/src/Template/Users/index.ctp
Wrote `/var/www/html/src/Template/Users/index.ctp`

Baking `view` view file...

Creating file /var/www/html/src/Template/Users/view.ctp
Wrote `/var/www/html/src/Template/Users/view.ctp`

Baking `add` view file...

Creating file /var/www/html/src/Template/Users/add.ctp
Wrote `/var/www/html/src/Template/Users/add.ctp`

Baking `edit` view file...

Creating file /var/www/html/src/Template/Users/edit.ctp
Wrote `/var/www/html/src/Template/Users/edit.ctp`
Bake All complete.

参考サイト
Bookmarker Tutorial(CakePHP Cookbook 3.x documentation)

0 件のコメント:

コメントを投稿