PHP code example of eclipxe / engineworks-progress-status

1. Go to this page and download the library: Download eclipxe/engineworks-progress-status 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/ */

    

eclipxe / engineworks-progress-status example snippets


 declare(strict_types=1); 

// Create a new progress instance with the status of 10 total steps and the current message 'Starting...' 
use EngineWorks\ProgressStatus\Progress;
use EngineWorks\ProgressStatus\Status;

/* @var SplObserver $observer */

$pg = new Progress(Status::make(10, 'Starting...'), [$observer]);

/* @var SplObserver $otherObserver */
// add other observer to the progress
$pg->attach($otherObserver);

// This will fire the method update on $observer and $otherObserver with $pg as subject
$pg->increase('Step 1 done');

$status = $pg->getStatus();
echo sprintf(
    "Step %s of %s completed (%0.2f %%) ETA: %s\n",
    $status->getCurrent(),
    $status->getTotal(),
    $status->getRatio(),
    $status->getEstimatedTimeOfEnd() ? date('c', $status->getEstimatedTimeOfEnd()) : '--stalled--',
);