1. Go to this page and download the library: Download cabag/ext-backend-progress 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/ */
cabag / ext-backend-progress example snippets
namespace Cabag\BackendProgress\Examples\Command;
use Cabag\BackendProgress\Progress\BackendProgressAwareTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ExampleProgressBarCommand extends Command
{
use BackendProgressAwareTrait;
/**
* Configure command
*/
public function configure()
{
$this->registerTaskInProgress('your_awesome_task', 3);
parent::configure(); // TODO: Change the autogenerated stub
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|void
*/
public function execute(InputInterface $input, OutputInterface $output)
{
// Start the task
$this->startTask();
// Go to the next step
$this->nextStep();
// Update the step label
$this->updateStepLabel('Executing part one of this step');
$array = [];
// Do some more for find $array
// ...
// Update in a loop
$amount = count($array);
foreach ($array as $key => $value) {
$this->updateStepLabel(sprintf('Update part %s from %d', $key, $amount));
// Do some processing
}
// Go to the next step and update label
$this->nextStep('Label for whole task (can be updated)');
$this->nextStep('This is the last step');
// If you execute nextStep too often, the total amount of steps will raise and the completion will stay at
// steps-1 until endTask is called
$this->nextStep('An additional step');
// End the task
$this->endTask();
// Set up how long a task should stay in the queue after finishing (default 60 seconds)
$this->cleanupTask(30);
// Negative values are put into absolute values, so this is equivalent
$this->cleanupTask(-30);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.