gpt4 book ai didi

php - 从 Laravel 命令中清除控制台

转载 作者:行者123 更新时间:2023-12-02 04:04:02 24 4
gpt4 key购买 nike

我正在为一个副项目使用 Lumen 框架,并创建了一个 artisan 命令,用于将一个小表写入终端。我遇到的麻烦是清理终端并重新绘制表格。

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');
}

关于php - 从 Laravel 命令中清除控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40409693/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com