$ bin/cake bake model Items
One moment while associations are detected.
Baking table class for Items...
Creating file /var/www/html/src/Model/Table/ItemsTable.php
Wrote `/var/www/html/src/Model/Table/ItemsTable.php`
Deleted `/var/www/html/src/Model/Table/.gitkeep`
Baking entity class for Item...
Creating file /var/www/html/src/Model/Entity/Item.php
Wrote `/var/www/html/src/Model/Entity/Item.php`
Deleted `/var/www/html/src/Model/Entity/.gitkeep`
Baking test fixture for Items...
Creating file /var/www/html/tests/Fixture/ItemsFixture.php
Wrote `/var/www/html/tests/Fixture/ItemsFixture.php`
Deleted `/var/www/html/tests/Fixture/.gitkeep`
Bake is detecting possible fixtures...
Baking test case for App\Model\Table\ItemsTable ...
Creating file /var/www/html/tests/TestCase/Model/Table/ItemsTableTest.php
Wrote `/var/www/html/tests/TestCase/Model/Table/ItemsTableTest.php`
Done
Doneとなれば、成功です。 以下のようにそれぞれファイルが作成されます。
/Model/Entity/Item.php
/Model/Table/ItemsTable.php
/tests/Fixture/ItemsFixture.php
/tests/TestCase/Model/Table/ItemsTableTest.php
cakePHP4でモデルを作成する-テストファイルが不要な場合
テストファイルが不要でモデルを作成
$ bin/cake bake model Items --no-test --no-fixture
以下のように実行されます。
$ bin/cake bake model Items --no-test --no-fixture
One moment while associations are detected.
Baking table class for Items...
Creating file /var/www/html/src/Model/Table/ItemsTable.php
Wrote `/var/www/html/src/Model/Table/ItemsTable.php`
Baking entity class for Item...
Creating file /var/www/html/src/Model/Entity/Item.php
Wrote `/var/www/html/src/Model/Entity/Item.php`
テストファイル抜きで作成されます。
/Model/Entity/Item.php
/Model/Table/ItemsTable.php
cakePHP4でモデルを作成する-テーブル名と異なるモデル名にしたい場合
テーブル名と異なるモデル名にする場合
$ bin/cake bake model SecoundItems --table items
以下のように実行されます。
$ bin/cake bake model SecoundItems --table items
One moment while associations are detected.
Baking table class for SecoundItems...
Creating file /var/www/html/src/Model/Table/SecoundItemsTable.php
Wrote `/var/www/html/src/Model/Table/SecoundItemsTable.php`
Baking entity class for SecoundItem...
Creating file /var/www/html/src/Model/Entity/SecoundItem.php
Wrote `/var/www/html/src/Model/Entity/SecoundItem.php`
Baking test fixture for SecoundItems...
Creating file /var/www/html/tests/Fixture/SecoundItemsFixture.php
Wrote `/var/www/html/tests/Fixture/SecoundItemsFixture.php`
Bake is detecting possible fixtures...
Baking test case for App\Model\Table\SecoundItemsTable ...
Creating file /var/www/html/tests/TestCase/Model/Table/SecoundItemsTableTest.php
Wrote `/var/www/html/tests/TestCase/Model/Table/SecoundItemsTableTest.php`
Done
itemsテーブルに対応するモデルがSecoundItemという名称で作成されます。
※bin/cake bake model SecoundItems –table items –no-test –no-fixtureとすれば、テストファイル抜きでモデルが作成されます。
コメント