ふたりはララベル (Laravel PHP Framework)

PHPフレームワークのLaravelの体験記を書いていきます。こんなタイトルのブログですが萌え系アニメは一秒たりとも観たことがありません。

Laravelのソース内でArtisanコマンドを使う

Laravelのソース内でArtisanコマンドを使う。

Artisan::call('mybench:mycommand');

引数付きで使う例。

Artisan::call('mybench:mycommand', ['year' => 2014]);

引数付きで使う場合、自作コマンド側の引数受け取り部分はこうなる。

/**
 * Get the console command arguments.
 *
 * @return array
 */
protected function getArguments()
{
  return array(
    ['year', InputArgument::OPTIONAL, '年']
  );
}