1. Go to this page and download the library: Download abryb/console-handler 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/ */
abryb / console-handler example snippets
namespace App\Command;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Abryb\ConsoleHandler\ConsoleHandler;
use Abryb\ConsoleHandler\ConsoleHandlerAwareCommand;
use Abryb\ConsoleHandler\Section\Log\RotateLogSection;
use Abryb\ConsoleHandler\Section\ProgressBar\RegexProgressBarSection;
class MyCommand extends Command implements ConsoleHandlerAwareCommand
{
private $logger;
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
parent::__construct();
}
public function configureConsoleHandler(ConsoleHandler $consoleHandler)
{
$consoleHandler->setSections([
new RotateLogSection(),
new RegexProgressBarSection(
'#My loop with (?<maxCount>\\d+) items#', // start regex
'#Loop item \d+', // advance regex
'#Loop finished#', // finish regex
'Foo bar' // name of progress bar
),
]);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
// Do my very long job with loop ...
$this->logger->debug('My loop with 1000 items');
for ($i = 0; $i < 1000; $i++) {
usleep(500);
$this->logger->debug("Loop item {$i}");
}
$this->logger->debug("Loop finished");
return 0;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.