php – 在Laravel中播种数据库时使用进度条
发布时间:2020-12-14 19:49:45 所属栏目:大数据 来源:网络整理
导读:我必须将大量数据植入数据库中,并希望能够在发生这种情况时向用户显示进度条.我知道这是记录在案的: https://laravel.com/docs/master/artisan#registering-commands(刚刚上方) http://symfony.com/doc/2.7/components/console/helpers/progressbar.html 但
我必须将大量数据植入数据库中,并希望能够在发生这种情况时向用户显示进度条.我知道这是记录在案的:
> https://laravel.com/docs/master/artisan#registering-commands(刚刚上方) 但我在播种机中遇到问题. <?php use IlluminateDatabaseSeeder; class SubDivisionRangeSeeder extends Seeder { public function run() { $this->output->createProgressBar(10); for ($i = 0; $i < 10; $i++) { sleep(1); $this->output->advance(); } $this->output->finish(); } } 要么 <?php use IlluminateDatabaseSeeder; class SubDivisionRangeSeeder extends Seeder { public function run() { $this->output->progressStart(10); for ($i = 0; $i < 10; $i++) { sleep(1); $this->output->progressAdvance(); } $this->output->progressFinish(); } } 从https://mattstauffer.co/blog/advanced-input-output-with-artisan-commands-tables-and-progress-bars-in-laravel-5.1 有任何想法吗?
您可以通过$this-> command-> getOutput()访问输出
public function run() { $this->command->getOutput()->progressStart(10); for ($i = 0; $i < 10; $i++) { sleep(1); $this->command->getOutput()->progressAdvance(); } $this->command->getOutput()->progressFinish(); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |