2016-11-03 12 views
0

私はサイドプロジェクトにLumenフレームワークを使用しており、小さなテーブルを端末に書き込む職人のコマンドを作成しました。私がやっていることは、端末をクリアしてテーブルを再描画することです。Laravelコマンドからコンソールを消去する

public function fire() 
{ 
    $scraper = new scraper(); 
    $scores = $scraper->scrape(); 
    $i = 1; 
    while($i = 1) { 
     $table = new Table($this->getOutput()); 

     $table->setHeaders(array('', 'Score', 'Status')); 
     foreach($scores as $game) { 
      $table->addRow([$game->team1['name'], $game->team1['score'], new TableCell($game->gameStatus, array('rowspan' => 2))]); 
      $table->addRow([$game->team2['name'], $game->team2['score']]); 
      $table->addRow([new TableSeparator(), new TableSeparator(), new TableSeparator()]); 
     } 
     $table->render(); 
     sleep(5); 
     // Somehow clear the terminal 
    } 
} 

誰にでもアイデアはありますか?

+0

あなたは、「問題が発生した」について詳しく説明していただけますか? –

+0

@JoeC "問題がある"のように私はコンソールをクリアする方法をよく分かりません。 –

答えて

0

汚い修正はこのようなものになるだろう:

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { 
    system('cls'); 
} else { 
    system('clear'); 
} 
関連する問題