Search code examples
phpsymfonydoctrine-ormcommand

Access Command OutputInterface within a Doctrine Fixtures Load


I'm generating a huge amount of data fixtures using the awesome Faker Library, also using lorempixel.com to have some random images in my Symfony2 project. This takes some time (currently ~ 10 Minutes), so I was wondering if it is possible to access the Command OutputInterface somehow through the container interface and print the progress this way instead of echo'ing everything..

Maybe also to have a nice output with ProgressBar


Solution

  • It looks like ConsoleOutput doesn't need anything special and can be instantiated directly.

    use Symfony\Component\Console\Output\ConsoleOutput;
    
    // ...
    
    public function load(ObjectManager $manager)
    {
        $output = new ConsoleOutput();
    
        $output->writeln('<info>this works... </info>');
    }