Php 从Laravel命令中清除控制台
我将Lumen框架用于一个侧面项目,并创建了一个artisan命令,将一个小表写入终端。我遇到的问题是,清理终端并重新绘制表格Php 从Laravel命令中清除控制台,php,laravel,command-line,terminal,lumen,Php,Laravel,Command Line,Terminal,Lumen,我将Lumen框架用于一个侧面项目,并创建了一个artisan命令,将一个小表写入终端。我遇到的问题是,清理终端并重新绘制表格 public function fire() { $scraper = new scraper(); $scores = $scraper->scrape(); $i = 1; while($i = 1) { $table = new Table($this->getOutput()); $t
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
}
}
有人有什么想法吗?一个肮脏的修补程序应该是这样的:
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
system('cls');
} else {
system('clear');
}
你能详细解释一下“有麻烦吗”?@JoeC“有麻烦”就像我不知道如何完成清理控制台一样。