PHP code example of exfriend / laravel-overseer

1. Go to this page and download the library: Download exfriend/laravel-overseer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

exfriend / laravel-overseer example snippets


 
 
 namespace App\Robots\HackerNews;
 
 class Command extends \Exfriend\Robots\Console\Command
 {
 
     /**
      * The name and signature of the console command.
      *
      * @var string
      */
     protected $signature = 'scrape:hackernews';
 
     /**
      * The console command description.
      *
      * @var string
      */
     protected $description = 'Gets the latest 10 news titles from hackernews';
     
     // this is new thing
     protected $title = 'HackerNews Scraper';
 
     /**
      * Execute the console command.
      *
      * @return mixed
      */
     public function handle()
     {
         $this->line( 'Beginning scrape' );
         for ( $i = 1; $i < 10; $i++ )
         {
             sleep(2);
             
             /**
              place this where you need to check 
              if there is a pending "stop" command from API
              to terminate properly
             */
             $this->checkpoint();
             
             // you can set progress% 0..100
             $this->setProgress( $i*10 );
             $this->line( 'Scraping news #'.$i.' of 10');
         }
         $this->line( 'Bye!' );
     }
 
 }