Quantcast
Channel: 一言多いプログラマーの独り言
Viewing all articles
Browse latest Browse all 846

Laravel5.4でコマンド作成(Writing Commands)

$
0
0
Laravel5.4コマンドを作成(Writing Commands)してみました。意味のないコマンドですが、動いてくれています(笑)。

make:commandで、マンド作成

$ php artisan make:command MyTestCommand

/app/Console/Commands/MyTestCommand.php

class MyTestCommand extends Command
{
protected $signature = 'command:test123';

protected $description = 'Command no setsumei desu.';

public function handle()
{
print date("Y-m-d H:i:s")."\n" ;
}
}

/app/Console/Kernel.php(コマンド登録)

protected $commands = [
Commands\MyTestCommand::class
];

実行してみる

$ php artisan list

command
command:test123 Command no setsumei desu.

$ php artisan command:test123

2017-01-31 12:34:56

参考サイト
Writing Commands(Laravel)

Viewing all articles
Browse latest Browse all 846

Trending Articles