CakePHP 2.0系からバッチファイルの置き場所が変わりました。
app/Console/Command/
この中に『バッチ名+Shell.php』を設置する
AppShellを継承する場合は、
App::uses('AppShell', 'Console/Command');
class HogeShell extends AppShell {
public function main() {}
public function fuga() {}
public function test() {
$arg = $this->args[0];
}
}
AppShellを継承しない場合は
class HogeShell extends Shell {
public function main() {}
public function fuga() {}
public function test() {
$arg = $this->args[0];
}
}
実際にTerminalから実行する場合は、
/usr/bin/php /*****/app/Console/cake.php Hoge -app /*****/app/
1) /usr/bin/php ・・・ phpまでのパス
2) /*****/app/Console/cake.php ・・・ cake.phpまでのパス
3) Hoge ・・・ Shell.phpを除いたシェル名
4) -app ・・・ appコマンド
5) /*****/app/ ・・・ appまでのパス
メソッド名を指定しない場合自動出来に、main()メソッドが呼び出される
/usr/bin/php /*****/app/Console/cake.php Hoge fuga -app /*****/app/
シェル名の後に任意のメソッドを指定できる
更に
/usr/bin/php /*****/app/Console/cake.php Hoge test etc -app /*****/app/
パラメータを渡すことも可能
おかしいところがありましたら、ご指摘をお願いします。