Rodhos Soft

備忘録を兼ねた技術的なメモです。Rofhos SoftではiOSアプリ開発を中心としてAndroid, Webサービス等の開発を承っております。まずはご相談下さい。

Shell

チュートリアルを参照した。
コンソールツール、シェルとタスク - 3.x

src/Shell直下にHelloShell.phpを作る。

<?php
namespace App\Shell;

use Cake\Console\Shell;

class HelloShell extends Shell
{
    public function main()
    {
        $this->out('Hello world.');
    }

    public function heyThere($name = 'Anonymous')
    {
      $this->out('Hey there ' . $name);
      $this->_hoge();
    }

    // _が先頭にあるものは呼べない。
    public function _hoge()
    {
      $this->out('hoge');
    }
}
?>

実行は

./bin/cake hello

./bin/cake Hello hey_there name

等でできる。

bakeもできる。

 ./bin/cake bake shell User