A Piece Of CakePHP

cakephp5

CakePHPを使っている中で書き留めたメモです。

create-project

CakePHPに限りませんが、ここではCakePHPのプロジェクトを作成する方法を記載します。
以下のコマンドを実行するとCakePHP Application Skeletonをダウンロードしてセットアップします。
–prefer-distを付けるとスケルトンをzipでダウンロードしますので、–prefer-sourceよりも処理が速いです。CakePHPのバージョンを指定する場合は、:”5.*”とバージョンを追加します。

composer create-project --prefer-dist cakephp/app:"5.*" fuga

bake

使えるコマンドは以下の通りです。困ったらbake –helpを参照しましょう。

bin/cake bake all
bin/cake bake behavior
bin/cake bake cell
bin/cake bake command
bin/cake bake command_helper
bin/cake bake component
bin/cake bake controller
bin/cake bake controller all
bin/cake bake enum
bin/cake bake fixture
bin/cake bake fixture all
bin/cake bake form
bin/cake bake helper
bin/cake bake mailer
bin/cake bake middleware
bin/cake bake model
bin/cake bake model all
bin/cake bake plugin
bin/cake bake template
bin/cake bake template all
bin/cake bake test

bakeは、プロジェクトのルートで実行します。
「bin/cake bake 部品の種類 クラス名」の書式でコマンドを実行します。

bin/cake bake controller Users
bin/cake bake model Users
bin/cake bake template Users

プラグインの作成

プラグインを新規作成するには、「bin/cake bake 部品の種類 プラグイン名」の書式でコマンドを実行します。

bin/cake bake plugin PiyoPlug

プラグインの部品を作成するには、「bin/cake bake 部品の種類 –plugin プラグイン名 クラス名」の書式でコマンドを実行します。

bin/cake bake controller --plugin PiyoPlug Users

コメント

タイトルとURLをコピーしました