Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

stephan-v's avatar

How to implement console progress bar?

I am currently using a crawler that I wrote that I call from the terminal with a console command I wrote for the artisan console.

A crawler would be a perfect usecase for a progressbar like the example given in the docs:

http://laravel.com/docs/5.1/artisan#writing-output

Now I am wondering how to implement it with my code though. The example is pretty straigtforward but I am using my console command to call helper file where my crawler is located. The example has a foreach loop in the command file itself.

This is my code:

public function handle(Crawler $crawler)
    {
        $this->info(PHP_EOL . "updating the database with beers data from example.com" . PHP_EOL);

        return $crawler->startCrawler('https://www.example.com', 'product-block', '/\d+\,?\d*CL/i');
    }

The startCrawler method runs the crawler and then the crawler goes through an if statement statement to paginate through the website until it hits a 404. How can I implement it like this while my if statement is in an external helper class?

0 likes
1 reply

Please or to participate in this conversation.