Skip to content

Instantly share code, notes, and snippets.

@foaly-nr1
Last active December 18, 2019 16:18
Show Gist options
  • Save foaly-nr1/3c53513643402cfb85fdb43b3d890d81 to your computer and use it in GitHub Desktop.
Save foaly-nr1/3c53513643402cfb85fdb43b3d890d81 to your computer and use it in GitHub Desktop.
Pac Man style ProgressBar in Symfony command
<?php
namespace AppBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class PacManCommand extends ContainerAwareCommand
{
const COMMAND_NAME = 'app:pacman';
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName(self::COMMAND_NAME)
->setDescription('Eat all pac-dots')
;
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$progress = new ProgressBar($output, 10);
$progress->setProgressCharacter('ᗧ');
$progress->setEmptyBarCharacter('·');
$progress->start();
// ...
}
}
@foaly-nr1
Copy link
Author

php bin/console app:pacman
 0/10 [ᗧ···························]   0%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment